#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <map> using namespace std; #define maxn 1000000 + 10 int n, m; int h[maxn], q[maxn]; map<int, int> mark; void solve() { sort(h, h+n); int t; while(m--) { scanf("%d", &t); if(mark[t]) { cout<<0<<endl; continue; } mark[t] = 1; int ans =upper_bound(h, h+n, t) - lower_bound(h, h+n, t); cout<<ans<<endl; } } int main() { while(~scanf("%d%d", &n, &m)) { mark.clear(); for(int i=0; i<n; i++) scanf("%d", &h[i]); solve(); } return 0; }
时间: 2024-10-12 01:41:55