Submission #1224977

#TimeUsernameProblemLanguageResultExecution timeMemory
1224977crazy0215Hacker (BOI15_hac)C++20
20 / 100
23 ms4164 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define show(x) cout << #x << " " << x << "\n";
#define showds(x) cout << #x << " "; for(auto y : x) cout << y << " "; cout << "\n";
typedef pair<int, int> ii;

bool cmp(ii a, ii b) {
	if (a.fi==b.fi) return a.se<b.se;
	return a.fi<b.fi;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int a[n], ans=0, m=0;
    for (int i=0; i<n; i++) {
		cin >> a[i];
		ans+=a[i];
		if (i<=n/2) m+=a[i];
	}
    m-=a[0];
    //show(m)
    int mm=m;
    for (int i=n/2+1, j=1; i<n; i++, j++) {
        mm=mm-a[j]+a[i], m=max(m, mm);
        //show(mm)
    }
    //show(m)
    cout << ans-m;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...