# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
289750 |
2020-09-03T02:41:32 Z |
caoash |
Hacker (BOI15_hac) |
C++14 |
|
1000 ms |
4836 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
vi a(2 * n + 1);
a[0] = 0;
multiset<int> vals;
int SZ = (n + 1) / 2;
for (int i = 1; i <= n; i++) {
cin >> a[i];
a[n + i] = a[i];
}
for (int i = 1; i <= 2 * n; i++) {
a[i] += a[i - 1];
}
int ans = 0;
vi ret(n + 1, INT_MAX);
for (int i = 1; i <= 2 * n; i++) {
cerr << "i: " << i << '\n';
if (i + SZ - 1 <= 2 * n) {
vals.insert(a[i + SZ - 1] - a[i - 1]);
cerr << "adding: " << i << " " << i + SZ - 1 << '\n';
}
if (i > SZ) {
vals.erase(vals.find(a[i - 1] - a[i - 1 - SZ]));
cerr << "removing: " << i - SZ << " " << i - 1 << '\n';
}
cerr << "vals: " << '\n';
/*
for (int x : vals) {
cerr << x << " ";
}
*/
cerr << '\n';
int prev = ((i - 1) % n) + 1;
// cout << "i, prev: " << i << " " << prev << '\n';
ret[prev] = min(ret[prev], *vals.begin());
}
for (int i = 1; i <= n; i++) {
cerr << i << " " << ret[i] << '\n';
ans = max(ans, ret[i]);
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
21 ms |
384 KB |
Output is correct |
8 |
Correct |
20 ms |
384 KB |
Output is correct |
9 |
Correct |
20 ms |
512 KB |
Output is correct |
10 |
Correct |
20 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
384 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
21 ms |
384 KB |
Output is correct |
17 |
Correct |
20 ms |
384 KB |
Output is correct |
18 |
Correct |
20 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
21 ms |
384 KB |
Output is correct |
8 |
Correct |
20 ms |
384 KB |
Output is correct |
9 |
Correct |
20 ms |
512 KB |
Output is correct |
10 |
Correct |
20 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
384 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
21 ms |
384 KB |
Output is correct |
17 |
Correct |
20 ms |
384 KB |
Output is correct |
18 |
Correct |
20 ms |
512 KB |
Output is correct |
19 |
Correct |
34 ms |
560 KB |
Output is correct |
20 |
Correct |
67 ms |
504 KB |
Output is correct |
21 |
Correct |
53 ms |
416 KB |
Output is correct |
22 |
Correct |
201 ms |
856 KB |
Output is correct |
23 |
Correct |
335 ms |
1092 KB |
Output is correct |
24 |
Correct |
196 ms |
760 KB |
Output is correct |
25 |
Correct |
331 ms |
1144 KB |
Output is correct |
26 |
Correct |
345 ms |
1020 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
330 ms |
1016 KB |
Output is correct |
31 |
Correct |
336 ms |
1188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
29 ms |
384 KB |
Output is correct |
3 |
Correct |
343 ms |
924 KB |
Output is correct |
4 |
Execution timed out |
1096 ms |
4836 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
21 ms |
384 KB |
Output is correct |
8 |
Correct |
20 ms |
384 KB |
Output is correct |
9 |
Correct |
20 ms |
512 KB |
Output is correct |
10 |
Correct |
20 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
384 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
21 ms |
384 KB |
Output is correct |
17 |
Correct |
20 ms |
384 KB |
Output is correct |
18 |
Correct |
20 ms |
512 KB |
Output is correct |
19 |
Correct |
34 ms |
560 KB |
Output is correct |
20 |
Correct |
67 ms |
504 KB |
Output is correct |
21 |
Correct |
53 ms |
416 KB |
Output is correct |
22 |
Correct |
201 ms |
856 KB |
Output is correct |
23 |
Correct |
335 ms |
1092 KB |
Output is correct |
24 |
Correct |
196 ms |
760 KB |
Output is correct |
25 |
Correct |
331 ms |
1144 KB |
Output is correct |
26 |
Correct |
345 ms |
1020 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
330 ms |
1016 KB |
Output is correct |
31 |
Correct |
336 ms |
1188 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
29 ms |
384 KB |
Output is correct |
34 |
Correct |
343 ms |
924 KB |
Output is correct |
35 |
Execution timed out |
1096 ms |
4836 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |