# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1118651 |
2024-11-26T00:34:17 Z |
orcslop |
Hacker (BOI15_hac) |
C++17 |
|
228 ms |
34192 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define f first
#define s second
#define pii pair<int, int>
const int N = 5e5 + 5;
int n;
int v[N << 1];
multiset<int> ms;
priority_queue<pii, vector<pii>, greater<pii>> pq;
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i = 0; i < n; i++){
cin >> v[i];
v[i + n] = v[i];
}
for(int i = 1; i < 2 * n; i++){
v[i] += v[i - 1];
}
auto get_sum = [&](int x) -> int{
return v[x + (n - 1) / 2] - (x ? v[x - 1] : 0);
};
for(int i = 0; i < n; i++){
ms.insert(i);
pq.push({get_sum(i), i});
}
int ans = 0;
while(!pq.empty()){
if(ms.size()) ans = pq.top().f;
else break;
auto x = pq.top().s, d = (n + 1) / 2;
pq.pop();
while(d){
auto it = ms.lower_bound(x);
while(it != ms.end() && *it <= x + d - 1) {
ms.erase(it);
it = ms.lower_bound(x);
}
d = max(0, x + d - n);
x = 0;
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
592 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
472 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
352 KB |
Output is correct |
11 |
Correct |
1 ms |
484 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
352 KB |
Output is correct |
14 |
Correct |
2 ms |
352 KB |
Output is correct |
15 |
Correct |
1 ms |
352 KB |
Output is correct |
16 |
Correct |
2 ms |
484 KB |
Output is correct |
17 |
Correct |
2 ms |
352 KB |
Output is correct |
18 |
Correct |
1 ms |
352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
592 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
472 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
352 KB |
Output is correct |
11 |
Correct |
1 ms |
484 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
352 KB |
Output is correct |
14 |
Correct |
2 ms |
352 KB |
Output is correct |
15 |
Correct |
1 ms |
352 KB |
Output is correct |
16 |
Correct |
2 ms |
484 KB |
Output is correct |
17 |
Correct |
2 ms |
352 KB |
Output is correct |
18 |
Correct |
1 ms |
352 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
1 ms |
352 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
596 KB |
Output is correct |
23 |
Correct |
2 ms |
596 KB |
Output is correct |
24 |
Correct |
2 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
756 KB |
Output is correct |
26 |
Correct |
2 ms |
752 KB |
Output is correct |
27 |
Correct |
1 ms |
352 KB |
Output is correct |
28 |
Correct |
1 ms |
352 KB |
Output is correct |
29 |
Correct |
1 ms |
352 KB |
Output is correct |
30 |
Correct |
2 ms |
608 KB |
Output is correct |
31 |
Correct |
3 ms |
608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
352 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
596 KB |
Output is correct |
4 |
Correct |
27 ms |
5648 KB |
Output is correct |
5 |
Correct |
95 ms |
13572 KB |
Output is correct |
6 |
Correct |
128 ms |
17084 KB |
Output is correct |
7 |
Correct |
114 ms |
20384 KB |
Output is correct |
8 |
Correct |
220 ms |
33852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
592 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
472 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
352 KB |
Output is correct |
11 |
Correct |
1 ms |
484 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
352 KB |
Output is correct |
14 |
Correct |
2 ms |
352 KB |
Output is correct |
15 |
Correct |
1 ms |
352 KB |
Output is correct |
16 |
Correct |
2 ms |
484 KB |
Output is correct |
17 |
Correct |
2 ms |
352 KB |
Output is correct |
18 |
Correct |
1 ms |
352 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
1 ms |
352 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
596 KB |
Output is correct |
23 |
Correct |
2 ms |
596 KB |
Output is correct |
24 |
Correct |
2 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
756 KB |
Output is correct |
26 |
Correct |
2 ms |
752 KB |
Output is correct |
27 |
Correct |
1 ms |
352 KB |
Output is correct |
28 |
Correct |
1 ms |
352 KB |
Output is correct |
29 |
Correct |
1 ms |
352 KB |
Output is correct |
30 |
Correct |
2 ms |
608 KB |
Output is correct |
31 |
Correct |
3 ms |
608 KB |
Output is correct |
32 |
Correct |
1 ms |
352 KB |
Output is correct |
33 |
Correct |
2 ms |
504 KB |
Output is correct |
34 |
Correct |
2 ms |
596 KB |
Output is correct |
35 |
Correct |
27 ms |
5648 KB |
Output is correct |
36 |
Correct |
95 ms |
13572 KB |
Output is correct |
37 |
Correct |
128 ms |
17084 KB |
Output is correct |
38 |
Correct |
114 ms |
20384 KB |
Output is correct |
39 |
Correct |
220 ms |
33852 KB |
Output is correct |
40 |
Correct |
5 ms |
1108 KB |
Output is correct |
41 |
Correct |
8 ms |
1744 KB |
Output is correct |
42 |
Correct |
9 ms |
2256 KB |
Output is correct |
43 |
Correct |
67 ms |
13640 KB |
Output is correct |
44 |
Correct |
228 ms |
33800 KB |
Output is correct |
45 |
Correct |
45 ms |
6860 KB |
Output is correct |
46 |
Correct |
127 ms |
20428 KB |
Output is correct |
47 |
Correct |
201 ms |
33916 KB |
Output is correct |
48 |
Correct |
200 ms |
34192 KB |
Output is correct |
49 |
Correct |
214 ms |
33244 KB |
Output is correct |
50 |
Correct |
212 ms |
33216 KB |
Output is correct |