結果
| 問題 | 
                            No.2804 Fixer And Ratism
                             | 
                    
| コンテスト | |
| ユーザー | 
                             mogura
                         | 
                    
| 提出日時 | 2024-07-12 23:26:16 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,784 bytes | 
| コンパイル時間 | 4,577 ms | 
| コンパイル使用メモリ | 248,204 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-12 23:26:24 | 
| 合計ジャッジ時間 | 7,077 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 11 WA * 20 | 
ソースコード
#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){
  			while(cnt!=pc){
  				cnt--;
  				if(unrepair.size()==0){
  					auto itr=repair.begin();
  					cout<<mp[*itr]<<endl;
  					repair.erase(*itr);
  				}
  				else{
  					auto itr=unrepair.begin();
  					cout<<mp[*itr]<<endl;
  					unrepair.erase(*itr);
  				}
  			}
  		}
  	}
  	if(num==2){
  		ll x;cin>>x;
  		pc-=x;
  		if(cnt>pc){
  			while(cnt!=pc){
  				cnt--;
  				if(unrepair.size()==0){
  					auto itr=repair.begin();
  					cout<<mp[*itr]<<endl;
  					repair.erase(*itr);
  				}
  				else{
  					auto itr=unrepair.begin();
  					cout<<mp[*itr]<<endl;
  					unrepair.erase(*itr);
  				}
  			}
  		}
  	}
  	if(num==3){
  		string s;
  		ll x;
  		cin>>s>>x;
  		unrepair.erase(mp2[s]);
  		repair.insert(mp2[s]);
  		pc+=x;
  	}
  }
}
            
            
            
        
            
mogura