답안 #1111156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111156 2024-11-11T15:28:56 Z Ghulam_Junaid Hacker (BOI15_hac) C++17
100 / 100
348 ms 18504 KB
#include <bits/stdc++.h>
using namespace std;
 
const int N = 5e5 + 10;
int n, a[N], x[N];
 
int norm(int x){
    x %= n;
    x += n;
    x %= n;
    return x;
}
 
int main(){
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[i];
 
    int k = n / 2 + n % 2;
    for (int i = 0; i < k; i ++)
        x[0] += a[i];
 
    for (int i = 1; i < n; i ++)
        x[i] = x[i - 1] - a[i - 1] + a[(i + k - 1) % n];
 
    set<pair<int, int>> st;
    for (int i = 0; i < k; i ++)
        st.insert({x[i], i});
 
    int ans = 0;
    for (int i = k - 1; i < n + k - 1; i ++){
        ans = max(ans, (*st.begin()).first);
        st.erase({x[norm(i - k + 1)], norm(i - k + 1)});
        st.insert({x[norm(i + 1)], norm(i + 1)});
    }
 
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 2 ms 2384 KB Output is correct
6 Correct 1 ms 2552 KB Output is correct
7 Correct 1 ms 2496 KB Output is correct
8 Correct 1 ms 2556 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2560 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 2 ms 2384 KB Output is correct
6 Correct 1 ms 2552 KB Output is correct
7 Correct 1 ms 2496 KB Output is correct
8 Correct 1 ms 2556 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2560 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 2 ms 2384 KB Output is correct
23 Correct 4 ms 2820 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 5 ms 2640 KB Output is correct
26 Correct 3 ms 2808 KB Output is correct
27 Correct 1 ms 2556 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 2 ms 2640 KB Output is correct
31 Correct 2 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 3 ms 2640 KB Output is correct
4 Correct 36 ms 4956 KB Output is correct
5 Correct 106 ms 8608 KB Output is correct
6 Correct 133 ms 10312 KB Output is correct
7 Correct 166 ms 11908 KB Output is correct
8 Correct 348 ms 18216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 2 ms 2384 KB Output is correct
6 Correct 1 ms 2552 KB Output is correct
7 Correct 1 ms 2496 KB Output is correct
8 Correct 1 ms 2556 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2560 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 2 ms 2384 KB Output is correct
23 Correct 4 ms 2820 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 5 ms 2640 KB Output is correct
26 Correct 3 ms 2808 KB Output is correct
27 Correct 1 ms 2556 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 2 ms 2640 KB Output is correct
31 Correct 2 ms 2640 KB Output is correct
32 Correct 1 ms 2384 KB Output is correct
33 Correct 1 ms 2384 KB Output is correct
34 Correct 3 ms 2640 KB Output is correct
35 Correct 36 ms 4956 KB Output is correct
36 Correct 106 ms 8608 KB Output is correct
37 Correct 133 ms 10312 KB Output is correct
38 Correct 166 ms 11908 KB Output is correct
39 Correct 348 ms 18216 KB Output is correct
40 Correct 6 ms 2640 KB Output is correct
41 Correct 9 ms 3124 KB Output is correct
42 Correct 13 ms 3576 KB Output is correct
43 Correct 110 ms 8596 KB Output is correct
44 Correct 272 ms 18248 KB Output is correct
45 Correct 45 ms 5456 KB Output is correct
46 Correct 151 ms 11848 KB Output is correct
47 Correct 327 ms 18248 KB Output is correct
48 Correct 250 ms 18504 KB Output is correct
49 Correct 204 ms 17588 KB Output is correct
50 Correct 225 ms 17480 KB Output is correct