結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
Magentor
|
| 提出日時 | 2024-07-03 12:38:11 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 985 bytes |
| コンパイル時間 | 3,624 ms |
| コンパイル使用メモリ | 274,732 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-11 23:10:47 |
| 合計ジャッジ時間 | 7,203 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = *begin(s);
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 = *begin(s);
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;
}
}
Magentor