結果
問題 |
No.2804 Fixer And Ratism
|
ユーザー |
|
提出日時 | 2024-07-19 13:53:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 123 ms / 2,000 ms |
コード長 | 1,684 bytes |
コンパイル時間 | 3,345 ms |
コンパイル使用メモリ | 140,552 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 13:53:08 |
合計ジャッジ時間 | 7,239 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<map> #define rep(i,n) for(i=0;i<(int)(n);i++) using namespace std; typedef long long ll; typedef pair<int,int> p; typedef pair<int,string> pp; typedef struct data{ int rate,q2; string s; data(int rrate=0,int qq2=0,string ss=""):rate(rrate),q2(qq2),s(ss){} bool operator<(const data& k)const{ return q2<k.q2||(q2==k.q2&&rate<k.rate); } }Data; int n,q; map<string,p> dic; vector<string> ans; int main(){ int i,j,cnt=0; string str; scanf("%d%d",&n,&q); while(q--){ scanf("%d",&i); switch(i){ case 1: cin>>str>>i; dic[str]=p(i,0); cnt++; break; case 2: scanf("%d",&i); n-=i; break; default: cin>>str>>i; n+=i; dic[str].second=1; } if(n<cnt){ vector<Data> tmp; vector<pp> ttmp; for(pair<string,p> x:dic){ tmp.push_back(Data(x.second.first,x.second.second,x.first)); } sort(tmp.begin(),tmp.end()); rep(i,cnt-n) ttmp.push_back(pp(tmp[i].rate,tmp[i].s)); sort(ttmp.begin(),ttmp.end()); rep(i,cnt-n) ans.push_back(ttmp[i].second); dic.clear(); for(;i<cnt;i++) dic[tmp[i].s]=p(tmp[i].rate,tmp[i].q2); cnt=n; //rep(i,ans.size())cout<<ans[i]<<" "<<flush;puts(""); } } rep(i,ans.size()) cout<<ans[i]<<endl; return 0; }