#include<iostream> #include<vector> #include<algorithm> usingnamespace std; intmain(){ int n,m; cin>>n>>m; vector<int>v(n+5); for(int i = 1;i<=n;++i){ cin>>v[i]; } sort(begin(v)+1,begin(v)+n+1); for(int i = 0;i<m;++i){ int t; cin>>t; int l = 1,r = n,ans = 0;//[1,n],ans==0 : no answer while(l<=r){ int m = (l+r)/2; if(v[m]>t){ r = m-1; } elseif(v[m]<t){ l = m+1; } else{ ans = m; break; } } cout<<ans<<endl; } }