# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
28907 |
2017-07-17T17:06:01 Z |
kavun |
Rice Hub (IOI11_ricehub) |
C++14 |
|
26 ms |
7488 KB |
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p[200000], bound;
int hub;
bool check(int x, int X[])
{
int m = (x-1) / 2;
if((x % 2) && (p[x-1] - p[m] - p[m-1] <= bound))
return true;
else if((x % 2 == 0) && (p[x-1] - p[m] - p[m-1] - X[m] <= bound))
return true;
for(int i = 1; i <= hub - x; i++)
{
int m = i + (x-1)/2;
if((x % 2) && (p[i+x-1] - p[m] - (p[m-1] - p[i-1]) <= bound))
return true;
else if((x % 2 == 0) && (p[i+x-1] - p[m] - (p[m-1] - p[i-1]) - X[m] <= bound))
return true;
}
return false;
}
int search(int lo, int hi, int X[])
{
int m = (lo + hi)/2;
if(lo == hi)
return lo;
if(hi == lo + 1)
m = hi;
if(check(m,X))
return search(m,hi,X);
else
return search(lo,m-1,X);
}
int besthub(int R, int L, int X[], long long B)
{
bound = B;
hub = R;
p[0] = X[0];
for(int i = 1; i < R; i++)
p[i] = p[i-1] + X[i];
return search(1,R,X);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7488 KB |
Output is correct |
2 |
Correct |
0 ms |
7488 KB |
Output is correct |
3 |
Correct |
0 ms |
7488 KB |
Output is correct |
4 |
Correct |
0 ms |
7488 KB |
Output is correct |
5 |
Correct |
0 ms |
7488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7488 KB |
Output is correct |
2 |
Correct |
0 ms |
7488 KB |
Output is correct |
3 |
Correct |
0 ms |
7488 KB |
Output is correct |
4 |
Correct |
0 ms |
7488 KB |
Output is correct |
5 |
Correct |
0 ms |
7488 KB |
Output is correct |
6 |
Correct |
0 ms |
7488 KB |
Output is correct |
7 |
Correct |
0 ms |
7488 KB |
Output is correct |
8 |
Correct |
0 ms |
7488 KB |
Output is correct |
9 |
Correct |
0 ms |
7488 KB |
Output is correct |
10 |
Correct |
0 ms |
7488 KB |
Output is correct |
11 |
Correct |
0 ms |
7488 KB |
Output is correct |
12 |
Correct |
0 ms |
7488 KB |
Output is correct |
13 |
Correct |
0 ms |
7488 KB |
Output is correct |
14 |
Correct |
0 ms |
7488 KB |
Output is correct |
15 |
Correct |
0 ms |
7488 KB |
Output is correct |
16 |
Correct |
0 ms |
7488 KB |
Output is correct |
17 |
Correct |
0 ms |
7488 KB |
Output is correct |
18 |
Correct |
0 ms |
7488 KB |
Output is correct |
19 |
Correct |
0 ms |
7488 KB |
Output is correct |
20 |
Correct |
0 ms |
7488 KB |
Output is correct |
21 |
Correct |
0 ms |
7488 KB |
Output is correct |
22 |
Correct |
0 ms |
7488 KB |
Output is correct |
23 |
Correct |
0 ms |
7488 KB |
Output is correct |
24 |
Correct |
0 ms |
7488 KB |
Output is correct |
25 |
Correct |
0 ms |
7488 KB |
Output is correct |
26 |
Correct |
0 ms |
7488 KB |
Output is correct |
27 |
Correct |
0 ms |
7488 KB |
Output is correct |
28 |
Correct |
0 ms |
7488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7488 KB |
Output is correct |
2 |
Correct |
0 ms |
7488 KB |
Output is correct |
3 |
Correct |
0 ms |
7488 KB |
Output is correct |
4 |
Correct |
0 ms |
7488 KB |
Output is correct |
5 |
Correct |
0 ms |
7488 KB |
Output is correct |
6 |
Correct |
0 ms |
7488 KB |
Output is correct |
7 |
Correct |
0 ms |
7488 KB |
Output is correct |
8 |
Correct |
0 ms |
7488 KB |
Output is correct |
9 |
Correct |
0 ms |
7488 KB |
Output is correct |
10 |
Correct |
0 ms |
7488 KB |
Output is correct |
11 |
Correct |
0 ms |
7488 KB |
Output is correct |
12 |
Correct |
0 ms |
7488 KB |
Output is correct |
13 |
Correct |
0 ms |
7488 KB |
Output is correct |
14 |
Correct |
0 ms |
7488 KB |
Output is correct |
15 |
Correct |
0 ms |
7488 KB |
Output is correct |
16 |
Correct |
0 ms |
7488 KB |
Output is correct |
17 |
Correct |
0 ms |
7488 KB |
Output is correct |
18 |
Correct |
0 ms |
7488 KB |
Output is correct |
19 |
Correct |
0 ms |
7488 KB |
Output is correct |
20 |
Correct |
0 ms |
7488 KB |
Output is correct |
21 |
Correct |
0 ms |
7488 KB |
Output is correct |
22 |
Correct |
0 ms |
7488 KB |
Output is correct |
23 |
Correct |
0 ms |
7488 KB |
Output is correct |
24 |
Correct |
0 ms |
7488 KB |
Output is correct |
25 |
Correct |
0 ms |
7488 KB |
Output is correct |
26 |
Correct |
0 ms |
7488 KB |
Output is correct |
27 |
Correct |
0 ms |
7488 KB |
Output is correct |
28 |
Correct |
0 ms |
7488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7488 KB |
Output is correct |
2 |
Correct |
3 ms |
7488 KB |
Output is correct |
3 |
Correct |
16 ms |
7488 KB |
Output is correct |
4 |
Correct |
13 ms |
7488 KB |
Output is correct |
5 |
Correct |
6 ms |
7488 KB |
Output is correct |
6 |
Correct |
9 ms |
7488 KB |
Output is correct |
7 |
Correct |
13 ms |
7488 KB |
Output is correct |
8 |
Correct |
26 ms |
7488 KB |
Output is correct |
9 |
Correct |
3 ms |
7488 KB |
Output is correct |
10 |
Correct |
6 ms |
7488 KB |
Output is correct |
11 |
Correct |
19 ms |
7488 KB |
Output is correct |
12 |
Correct |
16 ms |
7488 KB |
Output is correct |
13 |
Correct |
6 ms |
7488 KB |
Output is correct |
14 |
Correct |
6 ms |
7488 KB |
Output is correct |
15 |
Correct |
13 ms |
7488 KB |
Output is correct |
16 |
Correct |
13 ms |
7488 KB |
Output is correct |
17 |
Correct |
16 ms |
7488 KB |
Output is correct |
18 |
Correct |
9 ms |
7488 KB |
Output is correct |
19 |
Correct |
13 ms |
7488 KB |
Output is correct |
20 |
Correct |
16 ms |
7488 KB |
Output is correct |