Submission #259467

# Submission time Handle Problem Language Result Execution time Memory
259467 2020-08-07T21:47:45 Z amiratou Rice Hub (IOI11_ricehub) C++14
42 / 100
1000 ms 896 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll cum[100005],tab[100005];
ll sum(int a,int b){
	if(a>b)return 0;
	return cum[b]-(a?cum[a-1]:0);
}
ll cost(int i,int j,int x){
	ll idx=lower_bound(tab+i,tab+j+1,x)-tab;
	ll nb_a=idx-i,nb_b=j-idx+1;
	return nb_a*x-sum(i,idx-1)+sum(idx,j)-nb_b*x;
}

int besthub(int R, int L, int X[], long long B)
{
	for (int i = 0; i < R; ++i)
	{
		tab[i]=X[i];
		cum[i]=X[i];
		if(i)cum[i]+=cum[i-1];
	}
	int ans=1;
	for (int i = 0; i < R; ++i)
	{
		for (int j = i+1; j < R; ++j)
		{
			for (int k = i; k <= j; ++k)
			{
				if(cost(i,j,X[k])<=B){
					ans=max(ans,j-i+1);break;
				}
			}
			/*
			ll x=sum(i,j)/(j-i+1);
				if(cost(i,j,x)<=B)ans=max(ans,j-i+1);
				else{
					x=(sum(i,j)+(j-i))/(j-i+1);
					if(cost(i,j,x)<=B)ans=max(ans,j-i+1);
				}
			*/
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 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 2 ms 384 KB Output is correct
6 Correct 2 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 0 ms 384 KB Output is correct
10 Correct 0 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 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 2 ms 288 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 388 ms 504 KB Output is correct
22 Correct 387 ms 384 KB Output is correct
23 Correct 57 ms 384 KB Output is correct
24 Correct 60 ms 384 KB Output is correct
25 Correct 74 ms 384 KB Output is correct
26 Correct 88 ms 384 KB Output is correct
27 Correct 412 ms 392 KB Output is correct
28 Correct 400 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 384 KB Output is correct
2 Correct 19 ms 388 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 93 ms 384 KB Output is correct
5 Correct 351 ms 504 KB Output is correct
6 Correct 372 ms 384 KB Output is correct
7 Execution timed out 1075 ms 384 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 896 KB Time limit exceeded
2 Halted 0 ms 0 KB -