結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 21:53:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 881 bytes |
| コンパイル時間 | 4,251 ms |
| コンパイル使用メモリ | 212,036 KB |
| 最終ジャッジ日時 | 2025-02-22 03:55:36 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
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;
} else if (t == 2) {
int x;
cin >> x;
can_use -= x;
} else {
int x; string s;
cin >> s >> x;
mpp[s] = 2;
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;
}
}
}
}