結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
Pres1dent
|
| 提出日時 | 2024-07-12 21:50:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 153 ms / 2,000 ms |
| コード長 | 1,567 bytes |
| コンパイル時間 | 2,705 ms |
| コンパイル使用メモリ | 218,752 KB |
| 最終ジャッジ日時 | 2025-02-22 03:50:56 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, q; cin >> n >> q;
int pc = n;
map<string, int> rate;
map<int, string> name;
set<int> fixed;
set<int> stay;
vector<string> left;
for (int i = 0; i < q; i++) {
int op; cin >> op;
if (op == 1) {
string s; cin >> s;
int r; cin >> r;
stay.insert(r);
name[r] = s;
rate[s] = r;
// not saver
set<int> tmp;
for (auto e : stay) {
if (stay.size() - tmp.size() <= pc) {
break;
}
if (fixed.count(e)) continue;
tmp.insert(e);
}
// saver
for (auto e : stay) {
if (stay.size() - tmp.size() <= pc) {
break;
}
if (not fixed.count(e)) continue;
tmp.insert(e);
}
for (auto e : tmp) stay.erase(e), left.push_back(name[e]);
} else if (op == 2) {
int x; cin >> x;
pc -= x;
// not saver
set<int> tmp;
for (auto e : stay) {
if (stay.size() - tmp.size() <= pc) {
break;
}
if (fixed.count(e)) continue;
tmp.insert(e);
}
// saver
for (auto e : stay) {
if (stay.size() - tmp.size() <= pc) {
break;
}
if (not fixed.count(e)) continue;
tmp.insert(e);
}
for (auto e : tmp) stay.erase(e), left.push_back(name[e]);
} else {
string s; cin >> s;
int r = rate[s];
fixed.insert(r);
int x; cin >> x;
pc += x;
}
}
for (auto e : left) {
cout << e << endl;
}
}
Pres1dent