# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
402521 |
2021-05-11T22:02:18 Z |
Lobo |
Rice Hub (IOI11_ricehub) |
C++17 |
|
24 ms |
1484 KB |
#include <bits/stdc++.h>
#include <ricehub.h>
using namespace std;
const long long INFll = 1e18;
const int INFii = 1e9;
const long long mod = (long long) 1e9 + 7;
typedef long long ll;
typedef int ii;
typedef double dbl;
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define maxn 110000
//LEMBRAR DE MUDAR
ll ps[maxn];
int besthub(int R, int L, int X[], long long B){
ps[0] = 0;
for(ii i = R; i >= 1; i--) {
X[i] = X[i-1];
}
for(ii i = 1; i <= R; i++) {
ps[i] = ps[i-1] + X[i];
}
ii ans = 0;
for(ii i = 1; i <= R; i++) {
ii l = i;
ii r = R;
ii mid = (l+r)/2;
ii best = i;
while(l <= r) {
ii m = (i+mid)/2;
ll cost = X[m]*(m-i+1LL) - ps[m] + ps[i-1] + ps[mid] - ps[m] - X[m]*((ll) mid-m);
if(cost <= B) {
best = mid;
l = mid+1;
mid = (l+r)/2;
}
else {
r = mid-1;
mid = (l+r)/2;
}
}
ans = max(ans, best-i+1);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
2 ms |
364 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
460 KB |
Output is correct |
2 |
Correct |
4 ms |
460 KB |
Output is correct |
3 |
Correct |
21 ms |
1476 KB |
Output is correct |
4 |
Correct |
20 ms |
1476 KB |
Output is correct |
5 |
Correct |
10 ms |
816 KB |
Output is correct |
6 |
Correct |
9 ms |
804 KB |
Output is correct |
7 |
Correct |
20 ms |
1400 KB |
Output is correct |
8 |
Correct |
22 ms |
1356 KB |
Output is correct |
9 |
Correct |
10 ms |
844 KB |
Output is correct |
10 |
Correct |
10 ms |
892 KB |
Output is correct |
11 |
Correct |
24 ms |
1384 KB |
Output is correct |
12 |
Correct |
20 ms |
1476 KB |
Output is correct |
13 |
Correct |
12 ms |
808 KB |
Output is correct |
14 |
Correct |
9 ms |
844 KB |
Output is correct |
15 |
Correct |
15 ms |
1100 KB |
Output is correct |
16 |
Correct |
15 ms |
1120 KB |
Output is correct |
17 |
Correct |
18 ms |
1280 KB |
Output is correct |
18 |
Correct |
18 ms |
1356 KB |
Output is correct |
19 |
Correct |
19 ms |
1484 KB |
Output is correct |
20 |
Correct |
19 ms |
1352 KB |
Output is correct |