結果

問題 No.2804 Fixer And Ratism
ユーザー highlighterhighlighter
提出日時 2024-07-04 15:20:07
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 958 bytes
コンパイル時間 3,171 ms
コンパイル使用メモリ 256,004 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-11 23:11:01
合計ジャッジ時間 6,669 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 5 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 65 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 14 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 4 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 82 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 139 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 139 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 139 ms
5,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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-=x;
			while(N<0){
				P--;
				N++;
				if(!data2.empty()){
					pair<int,string> p=*begin(data2);
					cout << p.second << endl;
					data2.erase(p);
					continue;
				}
				pair<int,string> p=*begin(data1);
				//cout << p.second << endl;
				data1.erase(p);
			}
			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