Submission #131149

#TimeUsernameProblemLanguageResultExecution timeMemory
131149youssefbou62Hacker (BOI15_hac)C++14
40 / 100
94 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define allarr(a) a , a + n #define ll long long #define ull unsigned long long #define pb push_back #define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL) typedef pair<int, int> pi; typedef pair<ll,ll> pll; typedef pair<int,pi> trp ; typedef vector<pi> vpi; typedef vector<pll> vpll ; // int ab (int x ) { return (x>0?x:-x); } const int N = 5005 ; int a[N] , pref[N],n; int sum(int l , int r ){ if( l > r )return 0; if( l == 0 )return pref[r]; return pref[r]-pref[l-1] ; } int main(){ cin >> n ; for(int i= 0 ; i< n ; i++ )cin >> a[i] ; pref[0] = a[0] ; for(int i = 1 ; i < n ; i++ ){ pref[i] = pref[i-1] + a[i] ; } int ans = 0; for(int start = 0 ; start < n ; start ++ ){ int left , cnt = 1e9; for(int right = 1 ; right <= (n/2)+(n%2) ; right ++ ){ left = (n/2+n%2)-right; int s = sum(start,min(n-1,start+right-1)); s += sum(0,right - (n+1-start) ) ; s += sum(max(0,start-left),start-1); s += sum(n-(left-start),n-1); cnt = min(s,cnt); } ans = max ( cnt , ans ) ; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...