結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-04 18:12:03 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 145 ms / 2,000 ms |
| コード長 | 1,107 bytes |
| コンパイル時間 | 3,904 ms |
| コンパイル使用メモリ | 273,280 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-11 23:11:16 |
| 合計ジャッジ時間 | 7,693 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main() {
int N, Q;
cin >> N >> Q;
//人を並べるための配列
vector<pair<int,string>> P;
//使用可能にしたかどうかを管理する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;
P.push_back({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)P.size() > N) {
sort(P.begin(),P.end());
set<pair<int,string>> S;
int j=0;
while((int)P.size() > N) {
if(mp[P[j].second] == true && P[j].first <= 4000) {
P.push_back({P[j].first + 5000, P[j].second});
P.erase(P.begin()+j);
}
else {
S.insert({P[j].first%5000,P[j].second});
P.erase(P.begin()+j);
}
sort(P.begin(),P.end());
}
for(auto j : S) cout << j.second << endl;
}
}
}