Submission #75865090


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int Q=2e5+10;
int x,q,a,b;
priority_queue<int>l;//大根堆 
priority_queue<int,vector<int>,greater<int> >r;//小根堆 
void Balance(){
	while(l.size()>r.size()+1){
		r.push(l.top());
		l.pop();
	}
	while(r.size()>l.size()){
		l.push(r.top());
		r.pop();
	}
}
void Insert(int x){
	if(l.empty()||x<=l.top()){
		l.push(x);
	}
	else r.push(x);
	Balance();
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>x>>q;
	Insert(x);
	while(q--){
		cin>>a>>b;
		Insert(a);Insert(b);
		cout<<l.top()<<"\n";
	}
	return 0;
}

Submission Info

Submission Time
Task D - Chalkboard Median
User Axiom_
Language C++23 (GCC 15.2.0)
Score 400
Code Size 641 Byte
Status AC
Exec Time 52 ms
Memory 6840 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3416 KiB
00_sample_01.txt AC 1 ms 3644 KiB
00_sample_02.txt AC 1 ms 3516 KiB
01_random_00.txt AC 37 ms 6836 KiB
01_random_01.txt AC 52 ms 6608 KiB
01_random_02.txt AC 36 ms 6628 KiB
01_random_03.txt AC 36 ms 6672 KiB
01_random_04.txt AC 37 ms 6824 KiB
01_random_05.txt AC 36 ms 6692 KiB
01_random_06.txt AC 29 ms 6708 KiB
01_random_07.txt AC 44 ms 6736 KiB
01_random_08.txt AC 25 ms 5200 KiB
01_random_09.txt AC 43 ms 6752 KiB
01_random_10.txt AC 19 ms 5100 KiB
01_random_11.txt AC 44 ms 6748 KiB
01_random_12.txt AC 42 ms 6708 KiB
01_random_13.txt AC 42 ms 6624 KiB
01_random_14.txt AC 49 ms 6832 KiB
01_random_15.txt AC 49 ms 6616 KiB
01_random_16.txt AC 43 ms 6588 KiB
01_random_17.txt AC 42 ms 6528 KiB
01_random_18.txt AC 44 ms 6840 KiB
01_random_19.txt AC 44 ms 6608 KiB
01_random_20.txt AC 44 ms 6740 KiB
01_random_21.txt AC 44 ms 6620 KiB