Submission #136419

# Submission time Handle Problem Language Result Execution time Memory
136419 2019-07-25T09:27:32 Z junodeveloper Rice Hub (IOI11_ricehub) C++14
0 / 100
7 ms 760 KB
//#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int* a;
int n,l; long long b, T[2][100010], S[2];
vector<int> vx;
bool f(int x) {
	if(x==1)return true;
	int i;
	long long s1=0, s2=0, c=x/2-(x-1-x/2);
	for(i=0;i<x/2;i++) s1+=a[i];
	for(i=x/2;i<x;i++) s2+=a[i];
	long long r=vx[a[x/2]]*c-s1+s2;
	for(i=x;i<n;i++) {
		s1-=vx[a[i-x]], s2+=vx[a[i]];
		s2-=vx[a[i-x+x/2]], s1+=vx[a[i-x+x/2]];
		r=min(r,vx[a[i-x+1+x/2]]*c-s1+s2);
	}
	return r<=b;
}
int besthub(int R, int L, int X[], long long B)
{
	vx.clear();
	n=R,l=L,b=B,a=X;
	for(int i=0;i<R;i++) vx.push_back(X[i]);
	sort(vx.begin(),vx.end());
	vx.erase(unique(vx.begin(),vx.end()),vx.end());
	for(int i=0;i<R;i++) a[i]=lower_bound(vx.begin(),vx.end(),a[i])-vx.begin();
	int lo=0,hi=R;
	while(lo<hi){
		int mid=(lo+hi+1)/2;
		if(f(mid)) lo=mid;
		else hi=mid-1;
	}
	return lo;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 396 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -