結果
問題 |
No.2804 Fixer And Ratism
|
ユーザー |
|
提出日時 | 2024-07-12 21:42:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,422 bytes |
コンパイル時間 | 2,616 ms |
コンパイル使用メモリ | 212,164 KB |
最終ジャッジ日時 | 2025-02-22 03:44:23 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 31 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,Q; cin>>N>>Q; set<pair<int,string>>A,B; map<string,int>mp; vector<string>ans; while(Q--){ int t; cin>>t; if(t==1){ string s; int r; cin>>s>>r; mp[s]=r; A.insert(make_pair(r,s)); }else if(t==2){ int x; cin>>x; N-=x; }else{ string s; int x; cin>>s>>x; N+=x; if(A.count(make_pair(mp[s],s))){ A.erase(make_pair(mp[s],s)); B.insert(make_pair(mp[s],s)); } } while((int)A.size()+(int)B.size()>N){ if(A.size()){ auto id=A.begin(); ans.push_back((*id).second); A.erase(id); }else{ auto id=B.begin(); ans.push_back((*id).second); B.erase(id); } } } cout<<(int)ans.size()<<"\n"; for(auto s:ans)cout<<s<<"\n"; }