# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
856159 |
2023-10-02T18:12:54 Z |
aykhn |
Rice Hub (IOI11_ricehub) |
C++14 |
|
15 ms |
4188 KB |
#include "ricehub.h"
#include <bits/stdc++.h>
// author : aykhn
using namespace std;
typedef long long ll;
#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcount
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
vector<ll> pref;
ll getsum(int l, int r)
{
if (l > r) return 0;
if (!l) return pref[r];
return pref[r] - pref[l - 1];
}
int besthub(int n, int L, int X[], ll b)
{
ll x[n];
pref.assign(n + 1, 0);
for (int i = 0; i < n; i++) x[i] = X[i];
pref[0] = x[0];
for (int i = 1; i < n; i++) pref[i] = pref[i - 1] + x[i];
pref[n] = pref[n - 1];
int ans = 1;
for (int i = 1; i + 1 < n; i++)
{
int l = 1;
int r = min(i - 1, n - i - 1);
int best = 0;
while (l <= r)
{
int mid = (l + r) >> 1;
if (getsum(i + 1, i + mid) - getsum(i - mid, i - 1) <= b)
{
best = mid;
l = mid + 1;
}
else r = mid - 1;
}
ll sum = getsum(i + 1, i + best) - getsum(i - best, i - 1);
if (i - best - 1 >= 0 && sum + x[i] - x[i - best - 1] <= b) ans = max(ans, best * 2 + 2);
else if (i + best + 1 < n && sum + x[i + best + 1] - x[i] <= b) ans = max(ans, best * 2 + 2);
else ans = max(ans, best * 2 + 1);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
12 ms |
4184 KB |
Output is correct |
4 |
Correct |
12 ms |
4188 KB |
Output is correct |
5 |
Correct |
6 ms |
3464 KB |
Output is correct |
6 |
Correct |
6 ms |
3420 KB |
Output is correct |
7 |
Correct |
11 ms |
4036 KB |
Output is correct |
8 |
Correct |
11 ms |
4188 KB |
Output is correct |
9 |
Correct |
6 ms |
3388 KB |
Output is correct |
10 |
Correct |
6 ms |
3420 KB |
Output is correct |
11 |
Correct |
12 ms |
4140 KB |
Output is correct |
12 |
Correct |
15 ms |
4184 KB |
Output is correct |
13 |
Correct |
6 ms |
3420 KB |
Output is correct |
14 |
Correct |
6 ms |
3460 KB |
Output is correct |
15 |
Incorrect |
9 ms |
3928 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |