답안 #409620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409620 2021-05-21T08:14:01 Z iulia13 Hacker (BOI15_hac) C++14
100 / 100
484 ms 24380 KB
#include <iostream>
#include <set>

using namespace std;
const int N = 5e5 + 5;
int v[3 * N];
int sum[2 * N];
struct ura{
    int x, id;
};
set <pair<int, int>> s;
int main()
{
    int n, j, cnt = n, i;
    cin >> n; cnt = n;
    for (i = 1; i <= n; i++)
        cin >> v[i];
    for (j = 1; j < 3; j++)
        for (i = 1; i <= n; i++)
            v[++cnt] = v[i];

    int st = 1, dr = (n + 1) / 2;
    for (i = st; i <= dr; i++)
        sum[1] += v[i];
    while (st <= 2  * n)
    {
        sum[st + 1] = sum[st];
        sum[st + 1] -= v[st];
        st++;
        dr++;
        sum[st] += v[dr];
    }
    st = n - (n + 1) / 2 + 2;
    dr = n + 1;
    for (i = st; i <= dr; i++)
        s.insert({sum[i], i});
    pair<int, int> ans = *(s.begin());
    while (dr <= 2 * n)
    {
        s.erase({sum[st], st});
        st++;
        if (st == 15)
            st = 15;
        dr++;
        s.insert({sum[dr], dr});
        if (ans.first < (*(s.begin())).first)
            ans = *(s.begin());
    }

    cout << ans.first;
    return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:14:15: warning: 'n' is used uninitialized in this function [-Wuninitialized]
   14 |     int n, j, cnt = n, i;
      |               ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 3 ms 444 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 4 ms 460 KB Output is correct
26 Correct 4 ms 460 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 4 ms 460 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 61 ms 3736 KB Output is correct
5 Correct 158 ms 8896 KB Output is correct
6 Correct 221 ms 11072 KB Output is correct
7 Correct 249 ms 13136 KB Output is correct
8 Correct 484 ms 21784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 3 ms 444 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 4 ms 460 KB Output is correct
26 Correct 4 ms 460 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 4 ms 460 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 4 ms 460 KB Output is correct
35 Correct 61 ms 3736 KB Output is correct
36 Correct 158 ms 8896 KB Output is correct
37 Correct 221 ms 11072 KB Output is correct
38 Correct 249 ms 13136 KB Output is correct
39 Correct 484 ms 21784 KB Output is correct
40 Correct 7 ms 784 KB Output is correct
41 Correct 14 ms 1244 KB Output is correct
42 Correct 21 ms 1672 KB Output is correct
43 Correct 165 ms 9668 KB Output is correct
44 Correct 461 ms 24084 KB Output is correct
45 Correct 73 ms 4932 KB Output is correct
46 Correct 242 ms 14484 KB Output is correct
47 Correct 468 ms 23976 KB Output is correct
48 Correct 404 ms 24380 KB Output is correct
49 Correct 342 ms 23372 KB Output is correct
50 Correct 363 ms 23320 KB Output is correct