結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 21:49:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,288 bytes |
| コンパイル時間 | 2,060 ms |
| コンパイル使用メモリ | 182,364 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-12 21:49:44 |
| 合計ジャッジ時間 | 4,319 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "algo/debug.h"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long
void solve() {
int n, q;
cin >> n >> q;
set<pair<int, string>> spec, nor;
map<string, int> rat;
while (q--) {
int op;
cin >> op;
if (op == 1) {
string s; int x;
cin >> s >> x;
nor.insert({x, s});
rat[s] = x;
} else if (op == 2) {
int x; cin >> x;
n -= x;
} else {
string s;
int x;
cin >> s >> x;
n += x;
auto it = (nor.find({rat[s], s}));
if (it != nor.end()) {
nor.erase(it);
spec.insert({rat[s], s});
}
}
while (nor.size() + spec.size() > n) {
if (nor.size()) {
cout << (nor.begin()->second) << "\n";
nor.erase(nor.begin());
continue;
}
if (spec.size()) {
cout << (spec.begin() ->second) << "\n";
spec.erase(spec.begin());
continue;
}
break;
}
}
}
signed main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
#endif
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
// cerr << "Time elapsed: " << ((long double)clock() / CLOCKS_PER_SEC) << " s.\n";
}