# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
60838 |
2018-07-24T19:51:29 Z |
Vahan |
Rice Hub (IOI11_ricehub) |
C++17 |
|
41 ms |
7100 KB |
#include "ricehub.h"
#include<algorithm>
using namespace std;
int x[200000];
long long su[200000];
int bin(int l,int r,int v)
{
if(l==r)
return l;
if(l==r-1)
{
if(x[r]<=v)
return r;
else
return l;
}
int mid=(l+r)/2;
if(x[mid]<=v)
return bin(mid,r,v);
else
return bin(l,mid-1,v);
}
long long pat(int l,int r)
{
long long mig=(su[r]-su[l]+x[l])/(r-l+1);
long long f,e;
if((su[r]-su[l]+x[l])%(r-l+1)==0)
{
e=bin(l,r,mig);
return (e-l+1)*mig+su[l]-x[l]+su[r]-(r-e)*mig-2*su[e];
}
else
{
e=bin(l,r,mig);
f=bin(l,r,mig+1);
return min((e-l+1)*mig+su[l]-x[l]+su[r]-(r-e)*mig-2*su[e],(f-l+1)*(mig+1)+su[l]-x[l]+su[r]-(r-f)*(mig+1)-2*su[f]);
}
}
int besthub(int R, int L, int X[], long long B)
{
for(int r=0;r<R;r++)
{
x[r]=X[r];
if(r==0)
su[r]=X[r];
else
su[r]=su[r-1]+X[r];
}
int l=0;
int an=-1;
long long q;
for(int r=0;r<R;r++)
{
q=pat(l,r);
while(q>B)
{
l++;
q=pat(l,r);
}
an=max(an,r-l+1);
}
return an;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
4 ms |
488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
488 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
508 KB |
Output is correct |
5 |
Correct |
2 ms |
536 KB |
Output is correct |
6 |
Correct |
3 ms |
536 KB |
Output is correct |
7 |
Correct |
3 ms |
536 KB |
Output is correct |
8 |
Correct |
2 ms |
536 KB |
Output is correct |
9 |
Correct |
2 ms |
572 KB |
Output is correct |
10 |
Correct |
2 ms |
572 KB |
Output is correct |
11 |
Correct |
3 ms |
572 KB |
Output is correct |
12 |
Correct |
2 ms |
572 KB |
Output is correct |
13 |
Correct |
3 ms |
572 KB |
Output is correct |
14 |
Correct |
2 ms |
572 KB |
Output is correct |
15 |
Correct |
2 ms |
572 KB |
Output is correct |
16 |
Correct |
2 ms |
572 KB |
Output is correct |
17 |
Correct |
3 ms |
572 KB |
Output is correct |
18 |
Correct |
2 ms |
572 KB |
Output is correct |
19 |
Correct |
3 ms |
572 KB |
Output is correct |
20 |
Correct |
2 ms |
572 KB |
Output is correct |
21 |
Correct |
2 ms |
572 KB |
Output is correct |
22 |
Correct |
3 ms |
572 KB |
Output is correct |
23 |
Correct |
3 ms |
620 KB |
Output is correct |
24 |
Correct |
3 ms |
620 KB |
Output is correct |
25 |
Correct |
3 ms |
620 KB |
Output is correct |
26 |
Correct |
2 ms |
620 KB |
Output is correct |
27 |
Incorrect |
3 ms |
620 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
3 ms |
620 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
2 ms |
740 KB |
Output is correct |
6 |
Correct |
2 ms |
740 KB |
Output is correct |
7 |
Correct |
3 ms |
740 KB |
Output is correct |
8 |
Correct |
3 ms |
740 KB |
Output is correct |
9 |
Correct |
2 ms |
740 KB |
Output is correct |
10 |
Correct |
3 ms |
740 KB |
Output is correct |
11 |
Correct |
3 ms |
744 KB |
Output is correct |
12 |
Correct |
3 ms |
744 KB |
Output is correct |
13 |
Correct |
3 ms |
744 KB |
Output is correct |
14 |
Correct |
3 ms |
744 KB |
Output is correct |
15 |
Correct |
2 ms |
744 KB |
Output is correct |
16 |
Correct |
2 ms |
744 KB |
Output is correct |
17 |
Correct |
2 ms |
744 KB |
Output is correct |
18 |
Correct |
3 ms |
744 KB |
Output is correct |
19 |
Correct |
3 ms |
744 KB |
Output is correct |
20 |
Correct |
2 ms |
744 KB |
Output is correct |
21 |
Correct |
3 ms |
744 KB |
Output is correct |
22 |
Correct |
3 ms |
748 KB |
Output is correct |
23 |
Correct |
3 ms |
748 KB |
Output is correct |
24 |
Correct |
3 ms |
748 KB |
Output is correct |
25 |
Correct |
4 ms |
748 KB |
Output is correct |
26 |
Correct |
3 ms |
748 KB |
Output is correct |
27 |
Incorrect |
4 ms |
748 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
932 KB |
Output is correct |
2 |
Correct |
7 ms |
932 KB |
Output is correct |
3 |
Correct |
27 ms |
2212 KB |
Output is correct |
4 |
Correct |
40 ms |
2212 KB |
Output is correct |
5 |
Correct |
15 ms |
2212 KB |
Output is correct |
6 |
Correct |
14 ms |
2212 KB |
Output is correct |
7 |
Correct |
32 ms |
3556 KB |
Output is correct |
8 |
Correct |
41 ms |
4432 KB |
Output is correct |
9 |
Correct |
19 ms |
4432 KB |
Output is correct |
10 |
Correct |
18 ms |
4432 KB |
Output is correct |
11 |
Correct |
35 ms |
5992 KB |
Output is correct |
12 |
Correct |
38 ms |
7100 KB |
Output is correct |
13 |
Incorrect |
16 ms |
7100 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |