結果
問題 |
No.2804 Fixer And Ratism
|
ユーザー |
|
提出日時 | 2024-07-12 21:18:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 964 bytes |
コンパイル時間 | 2,827 ms |
コンパイル使用メモリ | 221,744 KB |
最終ジャッジ日時 | 2025-02-22 03:28:20 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,Q; cin >> N >> Q; int ok = N,mem = 0; set<tuple<int,int,string>> S; map<string,int> rate; while(Q--){ int t; cin >> t; if(t == 1){ string s; int r; cin >> s >> r; S.insert({0,r,s}); rate[s] = r; mem++; } if(t == 2){ int x; cin >> x; ok -= x; } if(t == 3){ string s; int x; cin >> s >> x; int ra = rate[s]; S.erase({0,ra,s}); S.insert({1,ra,s}); ok += x; } vector<pair<int,string>> era; while(ok < mem){ auto &[ig,ra,s] = *S.begin(); era.push_back({ra,s}); S.erase(S.begin()); mem--; } sort(era.begin(),era.end()); for(auto &[ign,s] : era) cout << s << "\n"; } }