結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 21:26:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 2,000 ms |
| コード長 | 935 bytes |
| コンパイル時間 | 2,299 ms |
| コンパイル使用メモリ | 191,788 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-12 21:26:09 |
| 合計ジャッジ時間 | 6,048 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n,Q;
cin >> n >> Q;
priority_queue<pair<int,string>,vector<pair<int,string>>,greater<pair<int,string>>> q;
set<string> e;
int L = 0;
while(Q--) {
int t;
cin >> t;
if(t == 1) {
string s;
int r;
cin >> s >> r;
q.push({r,s});
L++;
}
else if(t == 2) {
int x;
cin >> x;
n-=x;
}
else {
string s;
int x;
cin >> s >> x;
e.insert(s);
n+=x;
}
vector<pair<int,string>> left;
while(L > n) {
string s;
int r;
tie(r,s) = q.top();
if(e.count(s)) {
if(r < 1e9) {
r+=1e9;
q.pop();
q.push({r,s});
}
else {
q.pop();
left.push_back({r-1e9,s});
L--;
}
}
else {
L--;
left.push_back({r,s});
q.pop();
}
}
int l = left.size();
sort(left.begin(),left.end());
for(int i = 0; i < l; i++) cout << left[i].second << endl;
}
}