結果
問題 | No.2804 Fixer And Ratism |
ユーザー | cho435 |
提出日時 | 2024-07-12 23:01:05 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 1,517 bytes |
コンパイル時間 | 5,909 ms |
コンパイル使用メモリ | 282,312 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-12 23:01:14 |
合計ジャッジ時間 | 7,865 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) template<typename T> bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } template<typename T> bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; } struct io_setup { io_setup() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; using mint = atcoder::modint1000000007; int main(){ int nw,q; cin>>nw>>q; set<pair<int,string>> st,ust; map<string,int> mp; vector<string> ans; rep(lp,0,q){ int t; cin>>t; if(t==1){ string s; int r; cin>>s>>r; cin.ignore(); mp[s]=r; st.insert({r,s}); if(nw>0) nw--; else{ auto itr=st.begin(); assert(itr!=st.end()); ans.push_back(itr->second); st.erase(itr); } }else if(t==2){ int x; cin>>x; cin.ignore(); set<pair<int,string>> rt; rep(llp,0,x){ if(nw>0) nw--; else{ auto itr=st.begin(); if(itr==st.end()){ auto uitr=ust.begin(); assert(uitr!=ust.end()); rt.insert(*uitr); ust.erase(uitr); }else{ rt.insert(*itr); st.erase(itr); } } } for(auto[r,s]:rt) ans.push_back(s); }else if(t==3){ string s; int x; cin>>s>>x; cin.ignore(); if(st.count({mp[s],s})){ st.erase({mp[s],s}); ust.insert({mp[s],s}); } assert(ust.count({mp[s],s})); nw+=x; } } for(auto s:ans) cout<<s<<"\n"; }