結果
| 問題 | No.2804 Fixer And Ratism |
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-12-15 00:30:47 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 1,082 bytes |
| 記録 | |
| コンパイル時間 | 3,155 ms |
| コンパイル使用メモリ | 295,056 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-15 00:30:53 |
| 合計ジャッジ時間 | 5,850 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, q;
cin >> n >> q;
map<string, int> name2rate;
map<int, string> rate2name;
set<int> fixed, nfixed;
while (q--) {
int t;
cin >> t;
if (t == 1) {
string s;
int r;
cin >> s >> r;
rate2name[r] = s;
name2rate[s] = r;
nfixed.insert(r);
}
if (t == 2) {
int x;
cin >> x;
n -= x;
}
if (t == 3) {
string s;
int x;
cin >> s >> x;
fixed.insert(name2rate[s]);
nfixed.erase(name2rate[s]);
n += x;
}
priority_queue<int, vector<int>, greater<>> pq;
while (fixed.size() + nfixed.size() > n) {
auto& rem = (!nfixed.empty() ? nfixed : fixed);
int r = *rem.begin();
rem.erase(r);
pq.push(r);
}
while (!pq.empty()) {
int r = pq.top();
pq.pop();
cout << rate2name[r] << '\n';
}
}
return 0;
}
a01sa01to