Submission #146124

#TimeUsernameProblemLanguageResultExecution timeMemory
146124evpipisHacker (BOI15_hac)C++14
40 / 100
1078 ms1272 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...