1 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int maxn=1e6+5; int n,m,a[maxn]; void two_cuts(int goal,int n){ int l=1,r=n; while(l<r){ int mid=l+((r-l)>>1); if(a[mid]<goal)l=mid+1; else r=mid; } if(a[l]==goal)printf("%d ",l); else printf("-1 "); return; } int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } for(int i=0;i<m;i++){ int q; scanf("%d",&q); two_cuts(q,n); } return 0; }
- 1
Information
- ID
- 296
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 7
- Tags
- # Submissions
- 21
- Accepted
- 7
- Uploaded By