Submission #1111781

# Submission time Handle Problem Language Result Execution time Memory
1111781 2024-11-12T20:40:23 Z Kirill22 Hacker (BOI15_hac) C++17
100 / 100
317 ms 22272 KB
#include "bits/stdc++.h"
 
using namespace std;
 
void solve() {
    int n;
    cin >> n;
    vector<int> a(2 * n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i + n] = a[i];
    }
    vector<int> pref(a.size() + 1);
    for (int i = 1; i < (int) pref.size(); i++) {
        pref[i] = pref[i - 1] + a[i - 1];
    }
    int ans = 0, sz = n / 2, uk = 0;
    multiset<int> st;
    for (int i = 0; i < n; i++) {
        while (uk + sz - 1 < i + n) {
            st.insert({pref[uk + sz] - pref[uk]});
            uk++;
        }
        st.erase(st.find(pref[i + sz] - pref[i]));
        ans = max(ans, pref[n] - *st.rbegin());
    }
    cout << ans << '\n';
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
# 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 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 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 348 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 336 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 336 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 336 KB Output is correct
6 Correct 1 ms 504 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 348 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 336 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 460 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 3 ms 592 KB Output is correct
24 Correct 1 ms 592 KB Output is correct
25 Correct 2 ms 592 KB Output is correct
26 Correct 3 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 2 ms 592 KB Output is correct
4 Correct 27 ms 3920 KB Output is correct
5 Correct 81 ms 9040 KB Output is correct
6 Correct 109 ms 11088 KB Output is correct
7 Correct 121 ms 13384 KB Output is correct
8 Correct 317 ms 22088 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 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 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 348 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 336 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 460 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 3 ms 592 KB Output is correct
24 Correct 1 ms 592 KB Output is correct
25 Correct 2 ms 592 KB Output is correct
26 Correct 3 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 2 ms 592 KB Output is correct
35 Correct 27 ms 3920 KB Output is correct
36 Correct 81 ms 9040 KB Output is correct
37 Correct 109 ms 11088 KB Output is correct
38 Correct 121 ms 13384 KB Output is correct
39 Correct 317 ms 22088 KB Output is correct
40 Correct 5 ms 848 KB Output is correct
41 Correct 6 ms 1104 KB Output is correct
42 Correct 10 ms 1616 KB Output is correct
43 Correct 78 ms 9040 KB Output is correct
44 Correct 218 ms 22088 KB Output is correct
45 Correct 34 ms 4660 KB Output is correct
46 Correct 149 ms 13400 KB Output is correct
47 Correct 295 ms 22088 KB Output is correct
48 Correct 93 ms 22272 KB Output is correct
49 Correct 124 ms 21384 KB Output is correct
50 Correct 139 ms 21576 KB Output is correct