# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
146935 |
2019-08-26T17:21:24 Z |
karma |
Rice Hub (IOI11_ricehub) |
C++11 |
|
39 ms |
3320 KB |
#include <bits/stdc++.h>
#include "ricehub.h"
#define ll long long
using namespace std;
const int N = int(1e5) + 7;
ll sum[N], pos[N];
ll Cost(int l, int r)
{
int mid = (l + r) >> 1;
ll res = (ll)1e18, cost;
for(int i = max(mid - 1, l); i <= min(mid + 1, r); ++i) {
cost = 1ll * (i - l + 1) * pos[i] - (sum[i] - sum[l - 1]);
cost += sum[r] - sum[i] - 1ll * (r - i) * pos[i];
res = min(res, cost);
}
return res;
}
int besthub(int n, int l, int x[], ll b)
{
int res = 0, lef, rig, mid;
for(int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + (pos[i] = x[i - 1]);
for(int i = 1; i <= n; ++i) {
lef = 1, rig = i;
while(lef <= rig) {
mid = (lef + rig) >> 1;
if(Cost(mid, i) > b) lef = mid + 1;
else rig = mid - 1;
}
res = max(res, i - lef + 1);
}
return res;
}
/*int _n, _l, _x[N], _b;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if(fopen("test.inp", "r")) {
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
cin >> _n >> _l;
for(int i = 0; i < _n; ++i) cin >> _x[i];
cin >> _b;
cout << besthub(_n, _l, _x, _b);
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
380 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
380 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
380 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
4 ms |
412 KB |
Output is correct |
22 |
Correct |
4 ms |
504 KB |
Output is correct |
23 |
Correct |
4 ms |
504 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
4 ms |
504 KB |
Output is correct |
26 |
Correct |
4 ms |
504 KB |
Output is correct |
27 |
Correct |
4 ms |
504 KB |
Output is correct |
28 |
Correct |
4 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
896 KB |
Output is correct |
2 |
Correct |
8 ms |
888 KB |
Output is correct |
3 |
Correct |
37 ms |
3320 KB |
Output is correct |
4 |
Correct |
37 ms |
3320 KB |
Output is correct |
5 |
Correct |
18 ms |
1676 KB |
Output is correct |
6 |
Correct |
17 ms |
1656 KB |
Output is correct |
7 |
Correct |
34 ms |
3064 KB |
Output is correct |
8 |
Correct |
34 ms |
3064 KB |
Output is correct |
9 |
Correct |
18 ms |
1656 KB |
Output is correct |
10 |
Correct |
18 ms |
1656 KB |
Output is correct |
11 |
Correct |
38 ms |
3320 KB |
Output is correct |
12 |
Correct |
39 ms |
3320 KB |
Output is correct |
13 |
Correct |
19 ms |
1724 KB |
Output is correct |
14 |
Correct |
19 ms |
1656 KB |
Output is correct |
15 |
Correct |
29 ms |
2552 KB |
Output is correct |
16 |
Correct |
29 ms |
2552 KB |
Output is correct |
17 |
Correct |
34 ms |
2936 KB |
Output is correct |
18 |
Correct |
34 ms |
3056 KB |
Output is correct |
19 |
Correct |
37 ms |
3144 KB |
Output is correct |
20 |
Correct |
37 ms |
3192 KB |
Output is correct |