Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- int n,m,t[1000005],x;
- int binsrch(int a, int b, int x)
- {
- int l=(a+b)/2;
- if(t[l]>=x && t[l-1]<x){
- return l;
- }
- else{
- if(t[l]<x){
- a=l+1;
- }
- else{
- b=l-1;
- }
- if(a>b){
- return n;
- }
- binsrch(a,b,x);
- }
- }
- int main()
- {
- scanf("%d", &n);
- for(int i=0;i<n;i++)
- {
- scanf("%d", &t[i]);
- }
- scanf("%d", &m);
- for(int i=0;i<m;i++)
- {
- scanf("%d", &x);
- if(t[0]>=x){
- printf("%d ", n);
- }
- else{
- //printf("bin %d\n", binsrch(0,n-1,x));
- printf("%d ", n-(binsrch(0,n-1,x)));
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement