Submission #283608

# Submission time Handle Problem Language Result Execution time Memory
283608 2020-08-26T03:01:49 Z TMJN Rice Hub (IOI11_ricehub) C++17
100 / 100
27 ms 2944 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int X[100000];
long long S[100001];
long long B;

bool calc(int l,int r,int p){
	int pp=lower_bound(X+l,X+r+1,p)-X;
	return ((long long)p*(pp-l)-(S[pp]-S[l])+S[r+1]-S[pp]-(long long)p*(r-pp+1))<=B;
}

int besthub(int R, int L, int x[], long long b){
	int l,r;
	l=0;
	r=R+1;
	B=b;
	for(int i=0;i<R;i++){
		X[i]=x[i];
	}
	for(int i=0;i<R;i++){
		S[i+1]=S[i]+X[i];
	}
	while(l+1!=r){
		int m=(l+r)/2;
		bool f=false;
		for(int i=0;i<=R-m;i++){
			int p=min(L,X[(i+i+m-1)/2]);
			f|=calc(i,i+m-1,p);
		}
		if(f){
			l=m;
		}
		else{
			r=m;
		}
	}
	return l;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 768 KB Output is correct
2 Correct 7 ms 768 KB Output is correct
3 Correct 21 ms 2944 KB Output is correct
4 Correct 21 ms 2944 KB Output is correct
5 Correct 21 ms 1536 KB Output is correct
6 Correct 20 ms 1408 KB Output is correct
7 Correct 27 ms 2688 KB Output is correct
8 Correct 18 ms 2688 KB Output is correct
9 Correct 22 ms 1408 KB Output is correct
10 Correct 22 ms 1408 KB Output is correct
11 Correct 27 ms 2944 KB Output is correct
12 Correct 20 ms 2944 KB Output is correct
13 Correct 19 ms 1536 KB Output is correct
14 Correct 18 ms 1536 KB Output is correct
15 Correct 15 ms 2344 KB Output is correct
16 Correct 15 ms 2304 KB Output is correct
17 Correct 18 ms 2688 KB Output is correct
18 Correct 19 ms 2688 KB Output is correct
19 Correct 20 ms 2816 KB Output is correct
20 Correct 19 ms 2816 KB Output is correct