Submission #50723741


Source Code Expand

// LUOGU_RID: 148763821
#include <bits/stdc++.h>
#define int long long
const int N = 2e5+5;
using namespace std;
int q;
priority_queue<int> f;
queue<int> b;
signed main(){
	cin >> q;
	while(q--){
		int op,x;
		cin >> op;
		if(op==1) {
			cin >> x;
			b.push(x);
		}else if(op==2){
			if(f.size()) {cout<<-f.top()<<endl;f.pop();	}
			else {cout<<b.front()<<endl;b.pop();}
		}else{
			while(!b.empty()){
				f.push(-b.front());b.pop();
			}
		}
	}
	return 0;
}

Submission Info

Submission Time
Task E - Sorting Queries
User Expert_Dream
Language C++ 20 (gcc 12.2)
Score 500
Code Size 483 Byte
Status AC
Exec Time 150 ms
Memory 4976 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 16
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_max_random_00.txt, 01_max_random_01.txt, 01_max_random_02.txt, 02_all_1_00.txt, 03_all_1_2_00.txt, 04_all_3_00.txt, 05_unordered_hack_00.txt, 05_unordered_hack_01.txt, 06_unsort_hack_00.txt, 06_unsort_hack_01.txt, 07_sort_hack_00.txt, 07_sort_hack_01.txt, 08_mixed_hack_00.txt, 08_mixed_hack_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 6 ms 3440 KiB
00_sample_01.txt AC 1 ms 3484 KiB
01_max_random_00.txt AC 104 ms 3448 KiB
01_max_random_01.txt AC 104 ms 3488 KiB
01_max_random_02.txt AC 104 ms 3500 KiB
02_all_1_00.txt AC 64 ms 4664 KiB
03_all_1_2_00.txt AC 141 ms 3596 KiB
04_all_3_00.txt AC 17 ms 3496 KiB
05_unordered_hack_00.txt AC 138 ms 4232 KiB
05_unordered_hack_01.txt AC 138 ms 4304 KiB
06_unsort_hack_00.txt AC 149 ms 4924 KiB
06_unsort_hack_01.txt AC 150 ms 4920 KiB
07_sort_hack_00.txt AC 88 ms 4976 KiB
07_sort_hack_01.txt AC 88 ms 4916 KiB
08_mixed_hack_00.txt AC 119 ms 4056 KiB
08_mixed_hack_01.txt AC 118 ms 4068 KiB