Submission #741059

# Submission time Handle Problem Language Result Execution time Memory
741059 2023-05-13T13:39:58 Z Charizard2021 Hacker (BOI15_hac) C++17
100 / 100
130 ms 10580 KB
#include<bits/stdc++.h>
using namespace std;
int a[500005], n;
int range(int s, int e){
    if(s <= 0){
        return a[e] + (a[n] - a[s + n - 1]);
    }
    return a[e] - a[s - 1];
}
int cur1[500005], cur2[500005];
deque<int> dq, num;
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= n; i++) {
        cur1[i - 1] = range(i - (n - 1)/2, i);
    }
    for (int i = 0; i < n + (n - 1)/2; i++) {
        if(!num.empty() && num.front() == i - (n + 1) / 2){
            num.pop_front();
            dq.pop_front();
        }
        while (!dq.empty() && dq.back() > cur1[i % n]) {
            num.pop_back();
            dq.pop_back();
        }
        dq.push_back(cur1[i % n]);
        num.push_back(i);
        if(i - (n - 1)/2 >= 0){
            cur2[i - (n - 1)/2] = dq.front();
        }
    }
    cout << *max_element(cur2,cur2+n) << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 224 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 224 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 392 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 324 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 21 ms 1600 KB Output is correct
5 Correct 58 ms 3340 KB Output is correct
6 Correct 63 ms 4300 KB Output is correct
7 Correct 78 ms 5196 KB Output is correct
8 Correct 130 ms 8396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 224 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 392 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 324 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 21 ms 1600 KB Output is correct
36 Correct 58 ms 3340 KB Output is correct
37 Correct 63 ms 4300 KB Output is correct
38 Correct 78 ms 5196 KB Output is correct
39 Correct 130 ms 8396 KB Output is correct
40 Correct 3 ms 448 KB Output is correct
41 Correct 6 ms 596 KB Output is correct
42 Correct 9 ms 724 KB Output is correct
43 Correct 51 ms 3540 KB Output is correct
44 Correct 130 ms 8288 KB Output is correct
45 Correct 22 ms 1728 KB Output is correct
46 Correct 75 ms 5068 KB Output is correct
47 Correct 123 ms 8368 KB Output is correct
48 Correct 122 ms 10580 KB Output is correct
49 Correct 100 ms 9800 KB Output is correct
50 Correct 96 ms 9716 KB Output is correct