結果
問題 |
No.8016 unordered_mapなるたけ落とすマン
|
ユーザー |
|
提出日時 | 2020-03-09 04:15:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 123 ms / 1,000 ms |
コード長 | 618 bytes |
コンパイル時間 | 1,036 ms |
コンパイル使用メモリ | 78,292 KB |
実行使用メモリ | 6,144 KB |
最終ジャッジ日時 | 2024-11-07 20:40:57 |
合計ジャッジ時間 | 9,390 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> #include<vector> using namespace std; int N,M; long A[1<<17]; int ans[1<<17]; main() { cin>>N>>M; for(int i=0;i<N;i++)cin>>A[i]; sort(A,A+N); vector<pair<long,int> >B(M); for(int i=0;i<M;i++) { long b;cin>>b; B[i]=make_pair(b,i); } sort(B.begin(),B.end()); int ia=0; for(int i=0;i<M;i++) { if(i>0&&B[i-1].first==B[i].first) { ans[B[i].second]=ans[B[i-1].second]; } else { while(ia<N&&A[ia]<B[i].first)ia++; while(ia<N&&A[ia]==B[i].first) { ans[B[i].second]++; ia++; } } } for(int i=0;i<M;i++)cout<<ans[i]<<(i+1==M?"\n":" "); }