結果
問題 | No.2804 Fixer And Ratism |
ユーザー |
|
提出日時 | 2024-07-12 22:30:55 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 903 bytes |
コンパイル時間 | 2,387 ms |
コンパイル使用メモリ | 220,808 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-12 22:31:00 |
合計ジャッジ時間 | 4,735 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) void solve() { ll n, q; cin >> n >> q; set<tuple<ll, ll, string>> que; map<string, ll> rs; rep(qi, q) { ll t; cin >> t; if (t == 1) { string s; ll r; cin >> s >> r; que.emplace(1, -r, s); rs[s] = r; } else if (t == 2) { ll x; cin >> x; n -= x; } else if (t == 3) { string s; ll x; cin >> s >> x; n += x; ll r = rs[s]; que.erase({1, -r, s}); que.emplace(0, -r, s); } while (ll(que.size()) > n) { auto [i, r, s] = *que.rbegin(); cout << s << '\n'; que.erase({i, r, s}); } } } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }