답안 #104602

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104602 2019-04-08T10:30:29 Z alexpetrescu Hacker (BOI15_hac) C++14
40 / 100
1000 ms 1664 KB
#include <cstdio>
#include <algorithm>

//FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w");
#define fin stdin
#define fout stdout

#define MAXN 500009

int v[MAXN], u[MAXN], sum[MAXN];

inline int solve(int start, int n) {
    for (int i = (start + 1) % n, j = 1; j < n; i = (i + 1) % n, j++)
        u[j] = v[i];
    int l = n / 2;
    for (int i = 1; i < n; i++)
        sum[i] = sum[i - 1] + u[i];
    int ans = 0;
    for (int i = l; i < n; i++)
        ans = std::max(ans, sum[i] - sum[i - l]);
    return v[start] + sum[n - 1] - ans;
}

int main() {
    int n;
    fscanf(fin, "%d", &n);

    for (int i = 0; i < n; i++)
        fscanf(fin, "%d", &v[i]);

    int ans = 0;
    for (int start = 0; start < n; start++)
        ans = std::max(ans, solve(start, n));

    fprintf(fout, "%d\n", ans);

    fclose(fin);
    fclose(fout);
    return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:26:11: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf(fin, "%d", &n);
     ~~~~~~^~~~~~~~~~~~~~~
hac.cpp:29:15: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf(fin, "%d", &v[i]);
         ~~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 396 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 396 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 16 ms 384 KB Output is correct
21 Correct 9 ms 384 KB Output is correct
22 Correct 109 ms 384 KB Output is correct
23 Correct 293 ms 384 KB Output is correct
24 Correct 113 ms 384 KB Output is correct
25 Correct 303 ms 444 KB Output is correct
26 Correct 299 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 297 ms 384 KB Output is correct
31 Correct 302 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 301 ms 384 KB Output is correct
4 Execution timed out 1067 ms 1664 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 396 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 16 ms 384 KB Output is correct
21 Correct 9 ms 384 KB Output is correct
22 Correct 109 ms 384 KB Output is correct
23 Correct 293 ms 384 KB Output is correct
24 Correct 113 ms 384 KB Output is correct
25 Correct 303 ms 444 KB Output is correct
26 Correct 299 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 297 ms 384 KB Output is correct
31 Correct 302 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 301 ms 384 KB Output is correct
35 Execution timed out 1067 ms 1664 KB Time limit exceeded
36 Halted 0 ms 0 KB -