# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
511338 |
2022-01-15T14:35:23 Z |
AdamGS |
Rice Hub (IOI11_ricehub) |
C++14 |
|
21 ms |
2656 KB |
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e5+7;
ll sum[LIM], T[LIM];
ll Q(int l, int r) {
return sum[r]-(l?sum[l-1]:0);
}
int besthub(int n, int m, int P[], long long b) {
rep(i, n) {
if(i) sum[i]=sum[i-1];
T[i]=P[i];
sum[i]+=T[i];
}
ll ans=1;
rep(i, n) {
ll p=0, k=min(i, n-i-1);
while(p<k) {
ll sr=(p+k+1)/2;
if(Q(i+1, i+sr)-Q(i-sr, i-1)<=b) p=sr; else k=sr-1;
}
ans=max(ans, 2*p+1);
}
for(int i=1; i<n; ++i) {
ll p=0, k=min(i-1, n-i-1);
while(p<k) {
ll sr=(p+k+1)/2;
if(Q(i+1, i+sr)-Q(i-sr-1, i-1)+T[i]<=b) p=sr; else k=sr-1;
}
if(T[i]-T[i-1]<=b) ans=max(ans, 2*p+2);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
26 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 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 |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
296 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
716 KB |
Output is correct |
2 |
Correct |
4 ms |
716 KB |
Output is correct |
3 |
Correct |
18 ms |
2656 KB |
Output is correct |
4 |
Correct |
21 ms |
2552 KB |
Output is correct |
5 |
Correct |
10 ms |
1616 KB |
Output is correct |
6 |
Correct |
10 ms |
1612 KB |
Output is correct |
7 |
Correct |
15 ms |
2656 KB |
Output is correct |
8 |
Correct |
15 ms |
2636 KB |
Output is correct |
9 |
Correct |
11 ms |
1572 KB |
Output is correct |
10 |
Correct |
10 ms |
1484 KB |
Output is correct |
11 |
Correct |
17 ms |
2636 KB |
Output is correct |
12 |
Correct |
16 ms |
2636 KB |
Output is correct |
13 |
Correct |
9 ms |
1612 KB |
Output is correct |
14 |
Correct |
8 ms |
1612 KB |
Output is correct |
15 |
Correct |
12 ms |
2124 KB |
Output is correct |
16 |
Correct |
13 ms |
2124 KB |
Output is correct |
17 |
Correct |
15 ms |
2380 KB |
Output is correct |
18 |
Correct |
18 ms |
2332 KB |
Output is correct |
19 |
Correct |
15 ms |
2508 KB |
Output is correct |
20 |
Correct |
19 ms |
2524 KB |
Output is correct |