Submission #384655

#TimeUsernameProblemLanguageResultExecution timeMemory
384655zoooma13Hacker (BOI15_hac)C++14
40 / 100
1081 ms1644 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n ,sum = 0;
    scanf("%d",&n);
    int m = (n+1)/2;
    int l = n/2;
    vector <int> a(n);
    for(int&i : a)
        scanf("%d",&i) ,sum += i;
    a.insert(a.end() ,a.begin() ,a.end());
    int ans = 0;
    for(int i=0; i<n; i++){
        int mx = 0 ,sm = 0;
        for(int j=i+1; j<=i+l; j++)
            sm += a[j];
        mx = sm;
        for(int j=i+1; j+l<i+n; j++){
            sm = sm - a[j] + a[j+l];
            mx = max(mx ,sm);
        }
        ans = max(ans ,sum-mx);
    }
    printf("%d\n",ans);
}

Compilation message (stderr)

hac.cpp: In function 'int main()':
hac.cpp:8:9: warning: unused variable 'm' [-Wunused-variable]
    8 |     int m = (n+1)/2;
      |         ^
hac.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
hac.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |         scanf("%d",&i) ,sum += 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...