結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-07-14 17:04:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,103 bytes |
| コンパイル時間 | 2,293 ms |
| コンパイル使用メモリ | 210,588 KB |
| 最終ジャッジ日時 | 2025-02-22 06:40:41 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
int main() {
fast_io();
int n, q;
cin >> n >> q;
map<string, int> rate;
set<pair<int, string>> st_fixed, st_not_fixed;
for (; q--;) {
int type;
cin >> type;
if (type == 1) {
string s;
int r;
cin >> s >> r;
rate[s] = r;
st_not_fixed.insert({r, s});
if (st_fixed.size() + st_not_fixed.size() > n) {
auto it = st_not_fixed.begin();
cout << it->second << "\n";
st_not_fixed.erase(it);
}
} else if (type == 2) {
int x;
cin >> x;
n -= x;
while (st_fixed.size() + st_not_fixed.size() > n) {
if (!st_not_fixed.empty()) {
auto it = st_not_fixed.begin();
cout << it->second << "\n";
st_not_fixed.erase(it);
} else {
auto it = st_fixed.begin();
cout << it->second << "\n";
st_fixed.erase(it);
}
}
} else {
string s;
int x;
cin >> s >> x;
n += x;
if (st_not_fixed.count({rate[s], s})) {
st_fixed.insert({rate[s], s});
st_not_fixed.erase({rate[s], s});
}
}
}
}
eve__fuyuki