답안 #94116

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94116 2019-01-16T09:05:22 Z Kastanda Hacker (BOI15_hac) C++11
100 / 100
122 ms 18488 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1000006;
int n, A[N], P[N], G[N], MN[N * 2];
inline void Set(int i, int val)
{
    for (i += n + n - 1; i; i >>= 1)
        MN[i] = min(MN[i], val);
}
inline int Get(int l, int r)
{
    int Mn = INT_MAX;
    l += n + n - 1;
    r += n + n - 1;
    for (; l < r; l >>= 1, r >>= 1)
    {
        if (l & 1) Mn = min(Mn, MN[l]), l ++;
        if (r & 1) r --, Mn = min(Mn, MN[r]);
    }
    return (Mn);
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &A[i]), A[i + n] = A[i];

    int len = (n + 1) >> 1;

    for (int i = n; i < n + len; i++)
        P[n] += A[i];
    for (int i = n - 1; i; i--)
        P[i] = P[i + 1] + A[i] - A[i + len];

    for (int i = n + 1; i <= n + n; i++)
        P[i] = P[i - n];

    memset(MN, 63, sizeof(MN));
    for (int i = 1; i <= n + n; i++)
        Set(i, P[i]);

    int Mx = 0;
    for (int i = n + 1; i <= n + n; i++)
    {
        int le = (n - 2) >> 1;
        if (n & 1)
            le = (n - 2 + 1) >> 1;
        Mx = max(Mx, Get(i - le, i + 1));
    }
    return !printf("%d", Mx);
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
hac.cpp:26:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]), A[i + n] = A[i];
         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8188 KB Output is correct
2 Correct 8 ms 8188 KB Output is correct
3 Correct 8 ms 8184 KB Output is correct
4 Correct 8 ms 8184 KB Output is correct
5 Correct 7 ms 8184 KB Output is correct
6 Correct 8 ms 8184 KB Output is correct
7 Correct 8 ms 8184 KB Output is correct
8 Correct 8 ms 8108 KB Output is correct
9 Correct 8 ms 8184 KB Output is correct
10 Correct 8 ms 8184 KB Output is correct
11 Correct 8 ms 8184 KB Output is correct
12 Correct 8 ms 8184 KB Output is correct
13 Correct 8 ms 8184 KB Output is correct
14 Correct 8 ms 8184 KB Output is correct
15 Correct 8 ms 8184 KB Output is correct
16 Correct 8 ms 8184 KB Output is correct
17 Correct 8 ms 8184 KB Output is correct
18 Correct 8 ms 8184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8188 KB Output is correct
2 Correct 8 ms 8188 KB Output is correct
3 Correct 8 ms 8184 KB Output is correct
4 Correct 8 ms 8184 KB Output is correct
5 Correct 7 ms 8184 KB Output is correct
6 Correct 8 ms 8184 KB Output is correct
7 Correct 8 ms 8184 KB Output is correct
8 Correct 8 ms 8108 KB Output is correct
9 Correct 8 ms 8184 KB Output is correct
10 Correct 8 ms 8184 KB Output is correct
11 Correct 8 ms 8184 KB Output is correct
12 Correct 8 ms 8184 KB Output is correct
13 Correct 8 ms 8184 KB Output is correct
14 Correct 8 ms 8184 KB Output is correct
15 Correct 8 ms 8184 KB Output is correct
16 Correct 8 ms 8184 KB Output is correct
17 Correct 8 ms 8184 KB Output is correct
18 Correct 8 ms 8184 KB Output is correct
19 Correct 8 ms 8184 KB Output is correct
20 Correct 8 ms 8156 KB Output is correct
21 Correct 8 ms 8184 KB Output is correct
22 Correct 8 ms 8312 KB Output is correct
23 Correct 9 ms 8184 KB Output is correct
24 Correct 8 ms 8184 KB Output is correct
25 Correct 9 ms 8312 KB Output is correct
26 Correct 9 ms 8184 KB Output is correct
27 Correct 8 ms 8184 KB Output is correct
28 Correct 8 ms 8184 KB Output is correct
29 Correct 8 ms 8184 KB Output is correct
30 Correct 9 ms 8184 KB Output is correct
31 Correct 9 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8184 KB Output is correct
2 Correct 8 ms 8184 KB Output is correct
3 Correct 9 ms 8312 KB Output is correct
4 Correct 25 ms 9720 KB Output is correct
5 Correct 48 ms 12280 KB Output is correct
6 Correct 60 ms 13236 KB Output is correct
7 Correct 72 ms 14328 KB Output is correct
8 Correct 122 ms 18168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8188 KB Output is correct
2 Correct 8 ms 8188 KB Output is correct
3 Correct 8 ms 8184 KB Output is correct
4 Correct 8 ms 8184 KB Output is correct
5 Correct 7 ms 8184 KB Output is correct
6 Correct 8 ms 8184 KB Output is correct
7 Correct 8 ms 8184 KB Output is correct
8 Correct 8 ms 8108 KB Output is correct
9 Correct 8 ms 8184 KB Output is correct
10 Correct 8 ms 8184 KB Output is correct
11 Correct 8 ms 8184 KB Output is correct
12 Correct 8 ms 8184 KB Output is correct
13 Correct 8 ms 8184 KB Output is correct
14 Correct 8 ms 8184 KB Output is correct
15 Correct 8 ms 8184 KB Output is correct
16 Correct 8 ms 8184 KB Output is correct
17 Correct 8 ms 8184 KB Output is correct
18 Correct 8 ms 8184 KB Output is correct
19 Correct 8 ms 8184 KB Output is correct
20 Correct 8 ms 8156 KB Output is correct
21 Correct 8 ms 8184 KB Output is correct
22 Correct 8 ms 8312 KB Output is correct
23 Correct 9 ms 8184 KB Output is correct
24 Correct 8 ms 8184 KB Output is correct
25 Correct 9 ms 8312 KB Output is correct
26 Correct 9 ms 8184 KB Output is correct
27 Correct 8 ms 8184 KB Output is correct
28 Correct 8 ms 8184 KB Output is correct
29 Correct 8 ms 8184 KB Output is correct
30 Correct 9 ms 8184 KB Output is correct
31 Correct 9 ms 8192 KB Output is correct
32 Correct 8 ms 8184 KB Output is correct
33 Correct 8 ms 8184 KB Output is correct
34 Correct 9 ms 8312 KB Output is correct
35 Correct 25 ms 9720 KB Output is correct
36 Correct 48 ms 12280 KB Output is correct
37 Correct 60 ms 13236 KB Output is correct
38 Correct 72 ms 14328 KB Output is correct
39 Correct 122 ms 18168 KB Output is correct
40 Correct 9 ms 8440 KB Output is correct
41 Correct 12 ms 8568 KB Output is correct
42 Correct 13 ms 8824 KB Output is correct
43 Correct 49 ms 12168 KB Output is correct
44 Correct 115 ms 18168 KB Output is correct
45 Correct 27 ms 10108 KB Output is correct
46 Correct 78 ms 14172 KB Output is correct
47 Correct 120 ms 18208 KB Output is correct
48 Correct 121 ms 18488 KB Output is correct
49 Correct 121 ms 17612 KB Output is correct
50 Correct 112 ms 17548 KB Output is correct