hdu 5199 Gunner
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5199
简单题,stl水之。。。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 #include<set> 7 #include<map> 8 using std::map; 9 map<int, int> rec; 10 int main() { 11 #ifdef LOCAL 12 freopen("in.txt", "r", stdin); 13 freopen("out.txt", "w+", stdout); 14 #endif 15 int n, v, k; 16 while (~scanf("%d %d", &n, &k)) { 17 for (int i = 0; i < n; i++) { 18 scanf("%d", &v); 19 rec[v]++; 20 } 21 while (k--) { 22 scanf("%d", &v); 23 map<int, int>::iterator ite = rec.lower_bound(v); 24 if (ite == rec.end() || ite->first > v) puts("0"); 25 else printf("%d\n", ite->second), rec.erase(v); 26 } 27 } 28 return 0; 29 }
By: GadyPu 博客地址:http://www.cnblogs.com/GadyPu/ 转载请说明