"hopebetter"版题解
2025-08-19 10:31:57
发布于:浙江
3阅读
0回复
0点赞
#include<iostream>
#include<algorithm>
using namespace std;
using i64 = long long;
using i32 = int32_t;
#ifndef ONLINE_JUDGE
#include "test.h"
#else
#define debug(...) 42
#define debug_assert(...) 42
#endif
int main(){
cin.tie(0)->sync_with_stdio(0);
cout.tie(0)->sync_with_stdio(0);
i64 n,m,a[1000010];
cin>>n>>m;
for (i64 i=1;i<=n;i++) cin>>a[i];
while(m--){
i32 target;
cin>>target;
if (!binary_search(a+1,a+n+1,target)) cout<<-1<<' ';
else cout<<lower_bound(a+1,a+n+1,target)-a<<' ';
}
return 0;
}
这里空空如也
有帮助,赞一个