# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
481898 |
2021-10-22T07:36:59 Z |
uHyHn |
Rice Hub (IOI11_ricehub) |
C++14 |
|
13 ms |
1484 KB |
#include<bits/stdc++.h>
//IBOW
#define Task "IOI11_RICEHUB"
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
const int N = 2e5 + 10;
const int inf = 2e9 + 10;
const ll INF = 2e18 + 10;
const int MOD = 1e9 + 7;
bool ok(int va, int n, int l, int x[], ll B, ll pre[])
{
ll mn = INF;
for (int i = va; i <= n; ++i)
{
int rr = i;
int ll = i - va + 1;
int median = (rr + ll) / 2;
for (int j = max(0, median - 1); j <= min(n, median + 1); ++j)
{
mn = min(mn, x[j - 1] * 1LL * (j - ll + 1) - (pre[j] - pre[ll - 1]) + (pre[rr] - pre[j]) - x[j - 1] * 1LL * (rr - j));
}
}
return mn <= B;
}
int besthub(int n, int l, int x[], ll B)
{
ll pre[100010] = {};
pre[100010] = 0;
for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + x[i - 1];
int L = 1, R = n, ans = -1;
while (L <= R)
{
int mid = (L + R) / 2;
if (ok(mid, n, l, x, B, pre))
L = mid + 1, ans = mid;
else R = mid - 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
972 KB |
Output is correct |
2 |
Correct |
1 ms |
972 KB |
Output is correct |
3 |
Correct |
1 ms |
972 KB |
Output is correct |
4 |
Correct |
1 ms |
972 KB |
Output is correct |
5 |
Correct |
1 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
972 KB |
Output is correct |
2 |
Correct |
1 ms |
972 KB |
Output is correct |
3 |
Correct |
2 ms |
1072 KB |
Output is correct |
4 |
Correct |
1 ms |
972 KB |
Output is correct |
5 |
Correct |
1 ms |
972 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
972 KB |
Output is correct |
8 |
Correct |
1 ms |
1072 KB |
Output is correct |
9 |
Correct |
2 ms |
1072 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
972 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
1 ms |
972 KB |
Output is correct |
15 |
Correct |
1 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
972 KB |
Output is correct |
17 |
Correct |
2 ms |
1100 KB |
Output is correct |
18 |
Correct |
1 ms |
972 KB |
Output is correct |
19 |
Correct |
1 ms |
972 KB |
Output is correct |
20 |
Correct |
1 ms |
972 KB |
Output is correct |
21 |
Correct |
1 ms |
972 KB |
Output is correct |
22 |
Correct |
1 ms |
972 KB |
Output is correct |
23 |
Correct |
1 ms |
972 KB |
Output is correct |
24 |
Correct |
1 ms |
972 KB |
Output is correct |
25 |
Correct |
1 ms |
972 KB |
Output is correct |
26 |
Correct |
1 ms |
972 KB |
Output is correct |
27 |
Correct |
1 ms |
972 KB |
Output is correct |
28 |
Correct |
2 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
972 KB |
Output is correct |
2 |
Correct |
1 ms |
972 KB |
Output is correct |
3 |
Correct |
6 ms |
972 KB |
Output is correct |
4 |
Correct |
1 ms |
972 KB |
Output is correct |
5 |
Correct |
1 ms |
972 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
5 ms |
1040 KB |
Output is correct |
8 |
Correct |
1 ms |
972 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
972 KB |
Output is correct |
12 |
Correct |
2 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
1 ms |
972 KB |
Output is correct |
15 |
Correct |
1 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
972 KB |
Output is correct |
17 |
Correct |
1 ms |
972 KB |
Output is correct |
18 |
Correct |
1 ms |
972 KB |
Output is correct |
19 |
Correct |
3 ms |
972 KB |
Output is correct |
20 |
Correct |
1 ms |
972 KB |
Output is correct |
21 |
Correct |
2 ms |
1100 KB |
Output is correct |
22 |
Correct |
2 ms |
1100 KB |
Output is correct |
23 |
Correct |
1 ms |
972 KB |
Output is correct |
24 |
Correct |
3 ms |
1100 KB |
Output is correct |
25 |
Correct |
1 ms |
1100 KB |
Output is correct |
26 |
Correct |
2 ms |
1100 KB |
Output is correct |
27 |
Correct |
1 ms |
1100 KB |
Output is correct |
28 |
Correct |
1 ms |
1096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1100 KB |
Output is correct |
2 |
Correct |
5 ms |
1100 KB |
Output is correct |
3 |
Correct |
12 ms |
1484 KB |
Output is correct |
4 |
Correct |
11 ms |
1428 KB |
Output is correct |
5 |
Correct |
12 ms |
1276 KB |
Output is correct |
6 |
Correct |
12 ms |
1276 KB |
Output is correct |
7 |
Correct |
10 ms |
1468 KB |
Output is correct |
8 |
Correct |
10 ms |
1404 KB |
Output is correct |
9 |
Correct |
11 ms |
1272 KB |
Output is correct |
10 |
Correct |
13 ms |
1228 KB |
Output is correct |
11 |
Correct |
12 ms |
1480 KB |
Output is correct |
12 |
Correct |
11 ms |
1356 KB |
Output is correct |
13 |
Correct |
12 ms |
1240 KB |
Output is correct |
14 |
Correct |
11 ms |
1228 KB |
Output is correct |
15 |
Correct |
8 ms |
1356 KB |
Output is correct |
16 |
Correct |
8 ms |
1356 KB |
Output is correct |
17 |
Correct |
10 ms |
1388 KB |
Output is correct |
18 |
Correct |
12 ms |
1312 KB |
Output is correct |
19 |
Correct |
10 ms |
1356 KB |
Output is correct |
20 |
Correct |
11 ms |
1356 KB |
Output is correct |