# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
667481 |
2022-12-01T14:26:39 Z |
1bin |
Rice Hub (IOI11_ricehub) |
C++14 |
|
16 ms |
2520 KB |
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e5 + 5;
ll R, L, X[NMAX], B;
ll go(ll k){
ll a = 0, b = 0, c, m, p = 0;
for(int i = 0; i < k / 2; i++) a += X[i];
for(int i = k / 2; i < k; i++) b += X[i];
if(k & 1) p = X[k / 2];
c = -a + b - p;
for(int i = k; i < R; i++){
m = i - (k + 1) / 2;
a += -X[i - k] + X[m];
b += -X[m] + X[i];
if(k & 1) p = X[m + 1];
c = min(c, -a + b - p);
}
return c <= B;
}
int besthub(int R_, int L_, int X_[], ll B_){
R = R_; L = L_; B = B_;
for(int i = 0; i < R; i++) X[i] = X_[i];
ll l = 1, r = R, m;
while(l < r){
m = (l + r + 1) / 2;
if(go(m)) l = m;
else r = m - 1;
}
return l;
}
/*
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> R >> L >> B;
for(int i = 0; i < R; i++) cin >> X[i];
cout << besthub(R, L, X, B);
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
312 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
308 KB |
Output is correct |
22 |
Correct |
1 ms |
308 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
308 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
304 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
308 KB |
Output is correct |
19 |
Correct |
1 ms |
304 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
320 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
320 KB |
Output is correct |
24 |
Correct |
1 ms |
320 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
688 KB |
Output is correct |
2 |
Correct |
3 ms |
684 KB |
Output is correct |
3 |
Correct |
12 ms |
2452 KB |
Output is correct |
4 |
Correct |
13 ms |
2520 KB |
Output is correct |
5 |
Correct |
9 ms |
1236 KB |
Output is correct |
6 |
Correct |
6 ms |
1236 KB |
Output is correct |
7 |
Correct |
13 ms |
2148 KB |
Output is correct |
8 |
Correct |
11 ms |
2172 KB |
Output is correct |
9 |
Correct |
6 ms |
1108 KB |
Output is correct |
10 |
Correct |
6 ms |
1192 KB |
Output is correct |
11 |
Correct |
16 ms |
2508 KB |
Output is correct |
12 |
Correct |
13 ms |
2460 KB |
Output is correct |
13 |
Correct |
10 ms |
1204 KB |
Output is correct |
14 |
Correct |
6 ms |
1236 KB |
Output is correct |
15 |
Correct |
10 ms |
1968 KB |
Output is correct |
16 |
Correct |
9 ms |
1968 KB |
Output is correct |
17 |
Correct |
11 ms |
2232 KB |
Output is correct |
18 |
Correct |
11 ms |
2224 KB |
Output is correct |
19 |
Correct |
12 ms |
2356 KB |
Output is correct |
20 |
Correct |
11 ms |
2388 KB |
Output is correct |