結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
keisuke6
|
| 提出日時 | 2024-07-01 15:04:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 156 ms / 2,000 ms |
| コード長 | 987 bytes |
| コンパイル時間 | 2,822 ms |
| コンパイル使用メモリ | 218,804 KB |
| 最終ジャッジ日時 | 2025-02-22 01:43:24 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
int d = 4010;
map<string,int> m;
set<pair<int,string>> s;
for(int z=0;z<Q;z++){
int t;
cin>>t;
vector<pair<int,string>> A = {};
if(t == 2){
int x;
cin>>x;
N -= x;
while(s.size() > N){
pair<int,string> a = *s.begin();
A.push_back({a.first%d,a.second});
s.erase(a);
}
}
if(t == 1){
int x;
string ss;
cin>>ss>>x;
s.insert({x,ss});
m[ss] = x;
while(s.size() > N){
pair<int,string> a = *s.begin();
A.push_back({a.first%d,a.second});
s.erase(a);
}
}
if(t == 3){
int x;
string ss;
cin>>ss>>x;
N += x;
if(m[ss] < d){
s.erase({m[ss],ss});
m[ss] += d;
s.insert({m[ss],ss});
}
}
sort(A.begin(),A.end());
for(auto [a,b]:A) cout<<b<<endl;
}
}
keisuke6