結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
mogura
|
| 提出日時 | 2024-07-12 23:30:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 2,078 bytes |
| コンパイル時間 | 4,692 ms |
| コンパイル使用メモリ | 251,268 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-12 23:30:13 |
| 合計ジャッジ時間 | 6,997 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a));
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a),0LL)
using ll=long long;
using ld=long double;
using ull=unsigned long;
ll MOD=998244353;
using mint = static_modint<998244353>;
const int dx[]={0,1,0,-1,1,-1,1,-1};const int dy[]={1,0,-1,0,1,1,-1,-1};
const string ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZ";const string alpha="abcdefghijklmnopqrstuvwxyz";
int main(){
cin.tie(nullptr);
cout.tie(nullptr);
ios::sync_with_stdio(false);
ll n,q;cin>>n>>q;
ll pc=n;
map<ll,string>mp; //ratingからユーザーネームへ
map<string,ll>mp2;
set<ll>repair;
set<ll>unrepair;
ll cnt=0;
rep(i,q){
ll num;cin>>num;
if(num==1){
string s;
ll r;
cin>>s>>r;
mp[r]=s;
mp2[s]=r;
unrepair.insert(r);
cnt++;
if(cnt>pc){
vector<ll>ans(0);
while(cnt!=pc){
cnt--;
if(unrepair.size()==0){
auto itr=repair.begin();
//cout<<mp[*itr]<<endl;
ans.push_back(*itr);
repair.erase(*itr);
}
else{
auto itr=unrepair.begin();
//cout<<mp[*itr]<<endl;
ans.push_back(*itr);
unrepair.erase(*itr);
}
}
SORT(ans);
rep(i,ans.size()){cout<<mp[ans[i]]<<endl;}
}
}
if(num==2){
ll x;cin>>x;
pc-=x;
if(cnt>pc){
vector<ll>ans(0);
while(cnt!=pc){
cnt--;
if(unrepair.size()==0){
auto itr=repair.begin();
//cout<<mp[*itr]<<endl;
ans.push_back(*itr);
repair.erase(*itr);
}
else{
auto itr=unrepair.begin();
//cout<<mp[*itr]<<endl;
ans.push_back(*itr);
unrepair.erase(*itr);
}
}
SORT(ans);
rep(i,ans.size()){cout<<mp[ans[i]]<<endl;}
}
}
if(num==3){
string s;
ll x;
cin>>s>>x;
unrepair.erase(mp2[s]);
repair.insert(mp2[s]);
pc+=x;
}
}
}
mogura