結果

問題 No.2804 Fixer And Ratism
ユーザー highlighterhighlighter
提出日時 2024-07-04 15:36:41
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,118 bytes
コンパイル時間 2,973 ms
コンパイル使用メモリ 257,556 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-11 23:11:07
合計ジャッジ時間 6,378 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 36 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 24 ms
6,940 KB
testcase_09 AC 5 ms
6,944 KB
testcase_10 AC 18 ms
6,940 KB
testcase_11 AC 62 ms
6,944 KB
testcase_12 AC 51 ms
6,940 KB
testcase_13 AC 13 ms
6,944 KB
testcase_14 WA -
testcase_15 AC 5 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 4 ms
6,944 KB
testcase_20 WA -
testcase_21 AC 78 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 132 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 133 ms
6,944 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 135 ms
6,940 KB
testcase_29 WA -
testcase_30 AC 134 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
	set<pair<int,string>> data1;
	set<pair<int,string>> data2;
	int N,Q;
	cin >> N >> Q;
	int P=0;//部室にいる人数
	for(;Q--;){
		int c;
		cin >> c;
		if(c==1){
			string s;
			int r;
			cin >> s >> r;
			if(N==0){
				cout << s << endl;
				continue;
			}
			P++;
			N--;
			data2.insert(make_pair(r,s));
			continue;
		}
		if(c==2){
			int x;
			cin >> x;
			//x個使用不能に
			//もともとN+P台
			//N-x台とP人
			//N-xが負ならP人の方にしわ寄せ
			set<pair<int,string>> data3;
			N-=x;
			while(N<0){
				P--;
				N++;
				if(!data2.empty()){
					pair<int,string> p=*begin(data2);
					data2.erase(p);
					data3.insert(p);
					continue;
				}
				pair<int,string> p=*begin(data1);
				data1.erase(p);
				data3.insert(p);
			}
			for(auto i : data3){
				cout << i.second << endl;
			}
			continue;
		}
		string s;
		int x;
		cin >> s >> x;
		N+=x;
		pair<int,string> q=make_pair(-1,"");
		for(auto p : data2){
			if(p.second==s){
				q=p;
				break;
			}
		}
		if(q.first!=-1){
			data2.erase(q);
			data1.insert(q);
		}
	}
}
0