結果
問題 |
No.2804 Fixer And Ratism
|
ユーザー |
|
提出日時 | 2024-07-12 21:42:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,397 bytes |
コンパイル時間 | 1,259 ms |
コンパイル使用メモリ | 107,572 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-12 21:43:05 |
合計ジャッジ時間 | 5,091 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 20 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <string> using namespace std; using ll = long long; constexpr int iINF = 1'000'000'000; constexpr ll llINF = 1'000'000'000'000'000'000; int main () { int N, Q; cin >> N >> Q; map<int, string> normal, setuped; map<string, int> mp; vector<string> go_back; auto remove_min = [&] (map<int, string>& mp) { auto it = mp.lower_bound(-1); go_back.push_back(it->second); mp.erase(it->first); }; for (int i = 0; i < Q; i++) { int t; cin >> t; if (t == 1) { string s; int r; cin >> s >> r; normal[r] = s; mp[s] = r; if (N < normal.size() + setuped.size()) { remove_min(normal); } } if (t == 2) { int x; cin >> x; N -= x; while (N < normal.size() + setuped.size()) { if (0 < normal.size()) { remove_min(normal); continue; } remove_min(setuped); } } if (t == 3) { string s; int x; cin >> s >> x; N += x; setuped[mp[s]] = s; normal.erase(mp[s]); } } for (auto name : go_back) { cout << name << "\n"; } }