Submission #126651

#TimeUsernameProblemLanguageResultExecution timeMemory
126651miguelHacker (BOI15_hac)C++14
40 / 100
1086 ms1656 KiB
#include<bits/stdc++.h> using namespace std; #define rc(x) return cout<<x<<endl,0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define sz size() #define x first #define y second #define pi pair <int, int> #define pii pair <int, pi> #define vi vector <int> const ll mod = 1e9 + 7; int n, a[500001], s[1000001]; int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin>>n; for(int i=0; i<n; i++){ cin>>a[i]; if(i) s[i]=s[i-1]+a[i]; else s[i]=a[i]; } for(int i=n; i<=2*n; i++) s[i]=s[i-1]+a[i%n]; //for(int i=0; i<=2*n; i++) cout<<i<<" "<<s[i]<<endl; int ans=0; for(int i=0; i<n; i++){ int cur=0; for(int j=i+1; j<=(n+1)/2+i; j++) cur=max(cur, s[j+n/2]-s[j]); ans=max(ans, s[n-1]-cur); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...