結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 21:30:30 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,152 bytes |
| コンパイル時間 | 6,175 ms |
| コンパイル使用メモリ | 309,164 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-12 21:30:41 |
| 合計ジャッジ時間 | 7,215 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 20 |
ソースコード
#pragma GCC optimize("O3")
#ifdef LOCAL
#include "algo/debug_ver3.hpp"
#else
#define debug(...)
#define debugArr(...)
#endif
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, q;
cin >> n >> q;
set<pair<int, string>> a, b;
map<string, int> rates;
int cnt = n;
vector<string> ans;
for (int _ = 0; _ < q; ++_) {
int t;
cin >> t;
if (t == 1) {
string s;
int r;
cin >> s >> r;
b.insert({r, s});
rates[s] = r;
}
else if (t == 2) {
int x;
cin >> x;
cnt -= x;
}
else if (t == 3) {
string s;
int x;
cin >> s >> x;
cnt += x;
b.erase({rates[s], s});
a.insert({rates[s], s});
}
if ((int)a.size() <= cnt) {
while ((int)b.size() > cnt - (int)a.size()) {
ans.push_back(b.begin() -> second);
b.erase(b.begin());
}
}
else {
while (!b.empty()) {
ans.push_back(b.begin() -> second);
b.erase(b.begin());
}
while ((int)a.size() > cnt) {
ans.push_back(a.begin() -> second);
a.erase(a.begin());
}
}
/* debug(a, b, cnt); */
}
for (auto ans_i : ans) {
cout << ans_i << '\n';
}
}