Submission #75881084


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
priority_queue<int> x;
priority_queue<int> d;
int p,k,m,a,z[10001];
int main(){
	int n;
	cin>>n;
    cin>>m;
    for(int i=1;i<=2*m+1;i++){
        if(i==1){
            x.push(-1*n);
            continue;
        }
		cin>>a;
        if(i>1 && i%2==0){
           	int c = x.top();
           	if(a <= -1*c){
           		d.push(a);
			}
               else{
               	x.pop();
				x.push(-1*a);
				d.push(-1*c);
           	}
        }
		if(i>1 && i%2==1){
           	int c = d.top();
            if(a >= c){
              	x.push(-1*a);
			}
            else{
            	d.pop();
				d.push(a);
				x.push(-1*c);
            }
            cout<<-1*x.top()<<endl;
        }
    }
    return 0;
}

Submission Info

Submission Time
Task D - Chalkboard Median
User hydroxy
Language C++23 (GCC 15.2.0)
Score 400
Code Size 793 Byte
Status AC
Exec Time 192 ms
Memory 5196 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 3596 KiB
00_sample_01.txt AC 1 ms 3596 KiB
00_sample_02.txt AC 1 ms 3404 KiB
01_random_00.txt AC 149 ms 5088 KiB
01_random_01.txt AC 143 ms 5052 KiB
01_random_02.txt AC 156 ms 5060 KiB
01_random_03.txt AC 180 ms 4980 KiB
01_random_04.txt AC 180 ms 5080 KiB
01_random_05.txt AC 171 ms 5064 KiB
01_random_06.txt AC 124 ms 5064 KiB
01_random_07.txt AC 188 ms 5192 KiB
01_random_08.txt AC 107 ms 4296 KiB
01_random_09.txt AC 189 ms 5196 KiB
01_random_10.txt AC 79 ms 4320 KiB
01_random_11.txt AC 189 ms 5072 KiB
01_random_12.txt AC 151 ms 4976 KiB
01_random_13.txt AC 151 ms 4984 KiB
01_random_14.txt AC 192 ms 5008 KiB
01_random_15.txt AC 192 ms 5060 KiB
01_random_16.txt AC 190 ms 5048 KiB
01_random_17.txt AC 189 ms 5072 KiB
01_random_18.txt AC 190 ms 4964 KiB
01_random_19.txt AC 189 ms 5048 KiB
01_random_20.txt AC 190 ms 5020 KiB
01_random_21.txt AC 190 ms 5188 KiB