# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
207538 |
2020-03-07T20:18:40 Z |
robs |
Rice Hub (IOI11_ricehub) |
C++17 |
|
22 ms |
1528 KB |
#include "ricehub.h"
#include <bits/stdc++.h>
#define debug(args...) //fprintf(stderr, args)
typedef long long int lli;
using namespace std;
const int maxn = 2e5;
int s[maxn],cs[maxn],I,J,SUM;
int besthub(int R, int L, int X[], long long int B)
{
s[0] = X[0];
// debug("R-1 = %d\n",R-1);
for(int x = 1; x < R; x++)
s[x] = s[x-1] + X[x];
for(int x = 0; x < R; x++)
// debug("s[%d] = %d | d = %d\n",x,s[x],X[x]);
cs[R-1] = 0;
// debug("\n");
for(int x = R-2; x >= 0; x--)
cs[x] = cs[x+1] + X[R-1] - X[x];
// for(int x = 0; x < R; x++)
// debug("cs[%d] = %d | d = %d\n",x,cs[x],X[R-1]-X[x]);
// debug("\n\n");
int i = 0;
int j = 0;
lli resp = 0;
while(j < R)
{
int med = (i + j) / 2;
lli sumEsq = (cs[i] - cs[med]) - ((med - i)*(X[R-1] - X[med]));
// debug("%d - %d:\nsumEsq = %d = (%d-%d) - ((%d-%d)*(%d-%d))\n",i,j,sumEsq,cs[i],cs[med],med,i,X[R-1],X[med]);
lli sumDir = (s[j] - s[med]) - ((j - med)*X[med]);
// debug("sumDir = %d = (%d-%d) - ((%d-%d)*(%d-%d))\n",sumDir,s[j],s[med],j,med,X[med],X[0]);
lli sum = sumEsq + sumDir;
lli r = j - i + 1;
// debug("%d - %d(%d) %d %d -%d-\n\n",i,j,sum,sumEsq,sumDir,med);
if(sum <= B)
{
resp = max(resp, r);
j++;
}
else if(i == j)
{
j++;
}
else i++;
}
return resp;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
4 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
7 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
376 KB |
Output is correct |
23 |
Correct |
5 ms |
380 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
380 KB |
Output is correct |
23 |
Correct |
5 ms |
376 KB |
Output is correct |
24 |
Correct |
6 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
8 ms |
632 KB |
Output is correct |
3 |
Correct |
22 ms |
1528 KB |
Output is correct |
4 |
Incorrect |
21 ms |
1528 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |