# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
359270 |
2021-01-26T14:53:24 Z |
Pety |
Rice Hub (IOI11_ricehub) |
C++14 |
|
4 ms |
620 KB |
#include <bits/stdc++.h>
//#include "ricehub.h"
using namespace std;
vector<int> v;
vector<long long> sum;
long long cost (int l, int r) {
int mij = (l + r) / 2;
return 2 * (1ll * v[mij] * (mij - l + 1) - (sum[mij] - sum[l - 1]) + (sum[r] - sum[mij - 1]) - 1ll * (r - mij + 1) * v[mij]);
}
int besthub (int n, int l, int x[], long long b) {
sum.resize(n);
v.resize(n);
for (int i = 0; i < n; i++) {
sum[i] = (i ? sum[i - 1] + x[i] : x[i]);
v[i] = x[i];
}
int sol = 0;
for (int i = 0; i < n; i++) {
int st = i, dr = n - 1, ans = 0;
while (st <= dr) {
int mij = (st + dr) / 2;
if (cost(i, mij) <= b) {
ans = mij;
st = mij + 1;
}
else
dr = mij - 1;
}
sol = max(sol, ans - i + 1);
}
return sol;
}
/*int main () {
int x[] = {5, 10, 15, 20, 25, 31, 35, 40, 45, 50, 55, 59, 65, 70, 75, 80};
cout << besthub(16, 93, x, 1);
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |