結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-04 11:26:53 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 1,122 bytes |
| コンパイル時間 | 3,426 ms |
| コンパイル使用メモリ | 267,624 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-11 23:10:54 |
| 合計ジャッジ時間 | 6,912 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main() {
int N, Q;
cin >> N >> Q;
//人を並べるためのpriority_queue
priority_queue<pair<int,string>, vector<pair<int,string>>, greater<pair<int,string>>> que;
//使用可能にしたかどうかを管理するmap
map<string,bool> mp;
for(int i = 0;i < Q; i++) {
int q;
cin >> q;
if(q == 1) {
string s;
int r;
cin >> s >> r;
mp[s] = false;
que.push({r, s});
}
if(q == 2) {
int x;
cin >> x;
N -= x;
}
if(q == 3) {
string s;
int x;
cin >> s >> x;
mp[s] = true;
N += x;
}
if((q == 1 || q == 2) && (int)que.size() > N) {
set<pair<int,string>> S;
while((int)que.size() > N) {
if(mp[que.top().second] == true && que.top().first <= 4000) {
que.push({que.top().first + 5000, que.top().second});
que.pop();
}
else {
S.insert({que.top().first%5000,que.top().second});
que.pop();
}
}
for(auto j : S) {
cout << j.second << endl;
}
}
}
}