# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
672121 |
2022-12-14T19:33:25 Z |
Hacv16 |
Rice Hub (IOI11_ricehub) |
C++17 |
|
14 ms |
3260 KB |
#include<bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
const int MAX = 2e6 + 15;
const ll INF = 5e18 + 15;
ll n, x[MAX], px[MAX], L;
ll b;
ll sum(ll l, ll r){
return px[r] - (l == 0 ? 0LL : px[l - 1]);
}
bool f(ll s){
for(ll l = 0, r = s - 1; r < n; l++, r++){
ll m = (l + r) >> 1;
ll cost = 0;
cost += sum(m + 1, r) - (r - m) * x[m];
cost += (m - l) * x[m] - sum(l, m - 1);
if(cost <= b) return true;
}
return false;
}
int besthub(int _n, int _L, int _x[], ll _b){
n = _n; L = _L; b = _b;
for(int i = 0; i < n; i++)
x[i] = _x[i];
for(int i = 1; i < n; i++)
px[i] = x[i] + px[i - 1];
ll l = 0, r = MAX, ans = 1;
while(l <= r){ //bbin na resposta
int m = (l + r) >> 1;
if(f(m)) l = m + 1, ans = m;
else r = m - 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
220 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 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 |
352 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
596 KB |
Output is correct |
2 |
Correct |
3 ms |
596 KB |
Output is correct |
3 |
Correct |
13 ms |
2276 KB |
Output is correct |
4 |
Correct |
14 ms |
2196 KB |
Output is correct |
5 |
Correct |
7 ms |
1600 KB |
Output is correct |
6 |
Correct |
6 ms |
1620 KB |
Output is correct |
7 |
Correct |
11 ms |
3028 KB |
Output is correct |
8 |
Correct |
11 ms |
3028 KB |
Output is correct |
9 |
Correct |
6 ms |
1596 KB |
Output is correct |
10 |
Correct |
6 ms |
1592 KB |
Output is correct |
11 |
Correct |
13 ms |
3244 KB |
Output is correct |
12 |
Correct |
13 ms |
3260 KB |
Output is correct |
13 |
Correct |
7 ms |
1620 KB |
Output is correct |
14 |
Correct |
8 ms |
1600 KB |
Output is correct |
15 |
Correct |
10 ms |
2516 KB |
Output is correct |
16 |
Correct |
8 ms |
2516 KB |
Output is correct |
17 |
Correct |
14 ms |
3004 KB |
Output is correct |
18 |
Correct |
10 ms |
2900 KB |
Output is correct |
19 |
Correct |
11 ms |
3120 KB |
Output is correct |
20 |
Correct |
12 ms |
3088 KB |
Output is correct |