結果

問題 No.2804 Fixer And Ratism
ユーザー Akshaj Padmakar
提出日時 2024-07-12 22:35:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,310 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 182,788 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-12 22:35:14
合計ジャッジ時間 5,786 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 9 WA * 17 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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, ans;
map<string, int> rat;
while (q--) {
int op;
cin >> op;
if (op == 1) {
string s; int r;
cin >> s >> r;
nor.insert({r, s});
rat[s] = r;
} 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});
}
n = min(n, (int)1e9);
while (nor.size() + spec.size() > n) {
if (nor.size()) {
ans.insert(*nor.begin());
nor.erase(nor.begin());
} else if (spec.size()) {
ans.insert(*nor.begin());
spec.erase(spec.begin());
}
}
}
for (auto &x : ans) {
cout << x.second << '\n';
}
}
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";
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0