結果
問題 | No.2804 Fixer And Ratism |
ユーザー |
|
提出日時 | 2024-07-12 21:58:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 959 bytes |
コンパイル時間 | 2,895 ms |
コンパイル使用メモリ | 214,216 KB |
最終ジャッジ日時 | 2025-02-22 04:00:13 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; using P = pair<int, string>; int main () { int N, Q; cin >> N >> Q; priority_queue<P, std::vector<P>, greater<P>> pque1, pque2 ; map<string, int> mpp, rte; int can_use = N; int num_b = 0; while (Q--) { int t; cin >> t; if (t == 1) { string s; int r; cin >> s >> r; pque1.emplace(r, s); num_b ++; mpp[s] = 1; rte[s] = r; } else if (t == 2) { int x; cin >> x; can_use -= x; } else { int x; string s; cin >> s >> x; if (mpp[s] != 2) { mpp[s] = 2; pque2.emplace(rte[s], s); } can_use += x; } while (!pque1.empty() && num_b > can_use) { auto [r, s] = pque1.top(); pque1.pop(); if (mpp[s] == 1) { num_b --; cout << s << endl; mpp[s] = 0; } } while (!pque2.empty() && num_b > can_use) { auto [r, s] = pque2.top(); pque2.pop(); if (mpp[s] == 2) { num_b --; cout << s << endl; mpp[s] = 0; } } } }