QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#949548#9314. The Median of the Median of the MedianNaraFluorineRE 1ms7772kbC++145.2kb2025-03-24 01:53:422025-03-24 01:53:43

Judging History

This is the latest submission verdict.

  • [2025-03-24 01:53:43]
  • Judged
  • Verdict: RE
  • Time: 1ms
  • Memory: 7772kb
  • [2025-03-24 01:53:42]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define enter fout<<"\n";
#define space fout<<" ";
#define dot fout<<",";
#define oui fout<<"Yes\n";
#define non fout<<"No\n";
#define si fout<<"?";
#define i32 int
#define u32 unsigned int
#define i64 long long
#define u64 unsigned long long
#define i128 __int128
#define u128 unsigned __int128
#define debug(x) fout<<#x<<"="<<x<<"\n";
#define vdebug(a) fout<<#a<<"=";for(autox:a)fout<<x<<" ";fout<<"\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace fastio{
	const int bufl=1<<20;
	const double base1[16]={1,1e-1,1e-2,1e-3,1e-4,1e-5,1e-6,1e-7,1e-8,1e-9,1e-10,1e-11,1e-12,1e-13,1e-14,1e-15};
	const double base2[16]={1,1e1,1e2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15};
	struct IN{
		FILE *IT;char ibuf[bufl],*is=ibuf,*it=ibuf;
		IN(){IT=stdin;}IN(char *a){IT=fopen(a,"r");}
		inline char getChar(){if(is==it){it=(is=ibuf)+fread(ibuf,1,bufl,IT);if(is==it)return EOF;}return *is++;}
		template<typename Temp>inline void getInt(Temp &a){a=0;int b=0,c=getChar();while(c<48||c>57)b^=(c==45),c=getChar();while(c>=48&&c<=57)a=(a<<1)+(a<<3)+c-48,c=getChar();if(b)a=-a;}
		template<typename Temp>inline void getDouble(Temp &a){a=0;int b=0,c=getChar(),d=0;__int128 e=0,f=0;while(c<48||c>57)b^=(c==45),c=getChar();while(c>=48&&c<=57)e=(e<<1)+(e<<3)+c-48,c=getChar();if(c==46){c=getChar();while(c>=48&&c<=57)d++,f=(f<<1)+(f<<3)+c-48,c=getChar();}a=e+base1[d]*f;if(b)a=-a;}
		IN& operator>>(char &a){a=getChar();while(a<=32)a=getChar();return *this;}
		IN& operator>>(char *a){do{*a=getChar();}while(*a<=32);while(*a>32)*++a=getChar();*a=0;return *this;}
		IN& operator>>(string &a){char b=getChar();while(b<=32)b=getChar();while(b>32)a+=b,b=getChar();return *this;}
		IN& operator>>(int &a){getInt(a);return *this;}
		IN& operator>>(long long &a){getInt(a);return *this;}
		IN& operator>>(__int128 &a){getInt(a);return *this;}
		IN& operator>>(float &a){getDouble(a);return *this;}
		IN& operator>>(double &a){getDouble(a);return *this;}
		IN& operator>>(long double &a){getDouble(a);return *this;}
	};
	struct OUT{
		FILE *IT;char obuf[bufl],*os=obuf,*ot=obuf+bufl;int Eps;long double Acc;
		OUT(){IT=stdout,Eps=6,Acc=0.5;}OUT(char *a){IT=fopen(a,"w"),Eps=6,Acc=0.5;}
		inline void ChangEps(int x=6){Eps=x;}
		inline void flush(){fwrite(obuf,1,os-obuf,IT);os=obuf;}
		inline void putChar(int a){*os++=a;if(os==ot)flush();}
		template<typename Temp>inline void putInt(Temp a){if(a<0){putChar(45);a=-a;}if(a<10){putChar(a+48);return;}putInt(a/10);putChar(a%10+48);}
		template<typename Temp>inline void putLeading(Temp a,int b){if(!b)return;putLeading(a/10,b-1);putChar(a%10+48);}
		template<typename Temp>inline void putDouble(Temp a){if(a<0){putChar(45);a=-a;}__int128 ff=(a-(__int128)a)*base2[Eps+2],gg=0;ff+=50;while(ff>0){ff/=10;gg++;}__int128 b=a;if(gg==Eps+3){putInt(b+1);}else{putInt(b);}a-=b;a*=base2[Eps];b=a+Acc;putChar(46);putLeading(b,Eps);}
		OUT& operator<<(char a){putChar(a);return *this;}
		OUT& operator<<(const char *a){while(*a)putChar(*a++);return *this;}
		OUT& operator<<(string a){for(auto c:a)putChar(c);return *this;}
		OUT& operator<<(int a){putInt(a);return *this;}
		OUT& operator<<(long long a){putInt(a);return *this;}
		OUT& operator<<(__int128 a){putInt(a);return *this;}
		OUT& operator<<(unsigned int a){putInt(a);return *this;}
		OUT& operator<<(unsigned long long a){putInt(a);return *this;}
		OUT& operator<<(unsigned __int128 a){putInt(a);return *this;}
		OUT& operator<<(float a){putDouble(a);return *this;}
		OUT& operator<<(double a){putDouble(a);return *this;}
		OUT& operator<<(long double a){putDouble(a);return *this;}
		~OUT(){flush();}
	};
}
fastio::IN fin;
fastio::OUT fout;



int dat[100000];
int ddat[10010];
int tmp[1010];
int b[1010][1010],c[1010][1010];
long long n,m,res;


template<typename T>//比某个数大的数字都满足某个性质
char BSCheck(T num){
	int nnum=ddat[num];
	//checker自己写 
	for(int i=1;i<=n;++i){
		if(dat[i]<=nnum){
			tmp[i]=1;
		}else{
			tmp[i]=0;
		}
	}
	for(int i=1;i<=n;++i){
		tmp[i]+=tmp[i-1];
	}
	for(int i=1;i<=n;++i){
		for(int j=i;j<=n;++j){
			b[i][j]=((tmp[j]-tmp[i-1])>=(j-i+1+1)/2);
			// b[i][j]=((tmp[j]-tmp[i-1])>=(j-i+1+1)/2)?1:0;
		}
	}
	// fout<<num<<" "<<nnum<<"\n";
	// for(int i=1;i<=n;++i){
	// 	for(int j=1;j<=n;++j){
	// 		fout<<b[i][j]<<" ";
	// 	}
	// 	enter;
	// }
	// enter;

	for(int i=1;i<=n;++i){
		for(int j=i;j<=n;++j){
			b[i][j]+=b[i][j-1];
		}
	}
	for(int i=n;i>=1;--i){
		for(int j=i;j>=1;--j){
			b[j][i]+=b[j+1][i];
		}
	}

	int cnt=0;
	for(int i=1;i<=n;++i){
		for(int j=i;j<=n;++j){
			if(b[i][j]>=((j-i+1+1)*(j-i+1)/2+1)/2)cnt++;
		}
	}
	// fout<<num<<" "<<nnum<<"\n";
	// for(int i=1;i<=n;++i){
	// 	for(int j=1;j<=n;++j){
	// 		fout<<b[i][j]<<" ";
	// 	}
	// 	enter;
	// }
	// enter;
	// return cnt>=num;
	return cnt>=((n*(n+1)/2+1)/2);
}
template<typename T>
T BS(T l,T r){//范围[l,r]
	T mid;
	while(l<r){
		mid=(l+r)>>1;
		if(BSCheck(mid))r=mid;
		else l=mid+1;
	}
	return l;
}

//#define NaraFluorine
int main(){
	fin>>n;
	for(int i=1;i<=n;++i){
		fin>>dat[i];
		ddat[i]=dat[i];
	}
	sort(ddat+1,ddat+1+n);
	fout<<ddat[BS(1,(int)n)];
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7772kb

input:

4
1 3 1 7

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 7636kb

input:

8
3 3 8 4 5 3 8 5

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: -100
Runtime Error

input:

1883
935804604 209383625 842052635 830082014 365721046 29571412 503828250 261878653 304868479 615753663 149387882 137293208 553441715 659054561 809401479 786598486 257715598 738987349 749751119 675212261 214984147 816730618 204108936 529505526 670681192 375128179 445679706 531625791 954119640 739969...

output:


result: