Submission #146124

# Submission time Handle Problem Language Result Execution time Memory
146124 2019-08-22T09:41:23 Z evpipis Hacker (BOI15_hac) C++14
40 / 100
1000 ms 1272 KB
#include <bits/stdc++.h>
using namespace std;

const int len = 5e5+5, inf = 1e9;
int arr[len], out[len];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    for (int i = 0; i < n; i++)
        out[i] = inf;

    int k = (n+1)/2;
    for (int i = 0, j = 0, sum = 0; i < n; i++){
        while ((n+j-i)%n < k){
            sum += arr[j];
            j = (j+1)%n;
        }

        for (int l = i; l != j; l = (l+1)%n)
            out[l] = min(out[l], sum);

        sum -= arr[i];
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max(ans, out[i]);
    printf("%d\n", ans);
    return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
hac.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 8 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 52 ms 300 KB Output is correct
23 Correct 142 ms 376 KB Output is correct
24 Correct 54 ms 376 KB Output is correct
25 Correct 144 ms 504 KB Output is correct
26 Correct 138 ms 504 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 138 ms 376 KB Output is correct
31 Correct 139 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 138 ms 436 KB Output is correct
4 Execution timed out 1078 ms 1272 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 8 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 52 ms 300 KB Output is correct
23 Correct 142 ms 376 KB Output is correct
24 Correct 54 ms 376 KB Output is correct
25 Correct 144 ms 504 KB Output is correct
26 Correct 138 ms 504 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 138 ms 376 KB Output is correct
31 Correct 139 ms 420 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 138 ms 436 KB Output is correct
35 Execution timed out 1078 ms 1272 KB Time limit exceeded
36 Halted 0 ms 0 KB -