# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1114705 |
2024-11-19T12:50:15 Z |
Thunnus |
Hacker (BOI15_hac) |
C++17 |
|
325 ms |
26312 KB |
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define pii pair<int, int>
#define fi first
#define se second
#define sz(x) (int)(x).size()
signed main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n;
cin >> n;
const int SZ = (n + 1) / 2;
vi a(2 * n + 1);
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];
}
auto sum = [&](int l, int r) -> int {
if(!l) return a[r];
return a[r] - a[l - 1];
};
multiset<int> s;
vi ans(n + 1, LLONG_MAX);
for(int i = 1; i <= 2 * n; i++){
if(i + SZ - 1 <= 2 * n) s.emplace(sum(i, i + SZ - 1));
if(i > SZ) s.erase(s.find(sum(i - SZ, i - 1)));
ans[(i - 1) % n + 1] = min(ans[(i - 1) % n + 1], *s.begin());
}
cout << *max_element(ans.begin() + 1, ans.end()) << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 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 |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
500 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 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 |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
500 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
504 KB |
Output is correct |
22 |
Correct |
2 ms |
592 KB |
Output is correct |
23 |
Correct |
3 ms |
592 KB |
Output is correct |
24 |
Correct |
2 ms |
592 KB |
Output is correct |
25 |
Correct |
3 ms |
592 KB |
Output is correct |
26 |
Correct |
2 ms |
592 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
2 ms |
592 KB |
Output is correct |
31 |
Correct |
2 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
34 ms |
4432 KB |
Output is correct |
5 |
Correct |
96 ms |
10312 KB |
Output is correct |
6 |
Correct |
128 ms |
13128 KB |
Output is correct |
7 |
Correct |
151 ms |
15696 KB |
Output is correct |
8 |
Correct |
325 ms |
23880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 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 |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
500 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
504 KB |
Output is correct |
22 |
Correct |
2 ms |
592 KB |
Output is correct |
23 |
Correct |
3 ms |
592 KB |
Output is correct |
24 |
Correct |
2 ms |
592 KB |
Output is correct |
25 |
Correct |
3 ms |
592 KB |
Output is correct |
26 |
Correct |
2 ms |
592 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
2 ms |
592 KB |
Output is correct |
31 |
Correct |
2 ms |
592 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
3 ms |
592 KB |
Output is correct |
35 |
Correct |
34 ms |
4432 KB |
Output is correct |
36 |
Correct |
96 ms |
10312 KB |
Output is correct |
37 |
Correct |
128 ms |
13128 KB |
Output is correct |
38 |
Correct |
151 ms |
15696 KB |
Output is correct |
39 |
Correct |
325 ms |
23880 KB |
Output is correct |
40 |
Correct |
4 ms |
848 KB |
Output is correct |
41 |
Correct |
8 ms |
1360 KB |
Output is correct |
42 |
Correct |
12 ms |
2008 KB |
Output is correct |
43 |
Correct |
89 ms |
10576 KB |
Output is correct |
44 |
Correct |
280 ms |
25928 KB |
Output is correct |
45 |
Correct |
43 ms |
5500 KB |
Output is correct |
46 |
Correct |
135 ms |
15704 KB |
Output is correct |
47 |
Correct |
264 ms |
25928 KB |
Output is correct |
48 |
Correct |
208 ms |
26312 KB |
Output is correct |
49 |
Correct |
193 ms |
25420 KB |
Output is correct |
50 |
Correct |
197 ms |
25416 KB |
Output is correct |