Submission #1127345

#TimeUsernameProblemLanguageResultExecution timeMemory
1127345andrewpHacker (BOI15_hac)C++20
0 / 100
0 ms324 KiB
//Dedicated to my love,ivaziva #include <bits/stdc++.h> #define L(i, j, k) for(int i = (j); i <= (k); ++i) #define R(i, j, k) for(int i = (j); i >= (k); --i) #define ll long long #define sz(a) ((int) (a).size()) #define pb emplace_back #define me(a, x) memset(a, x, sizeof(a)) #define vi vector<int> #define i128 __int128 using namespace std; const int N = 1e5 + 7; int n, a[N], ps[N]; int get(int l, int r) { if(r < l) return 0; return (ps[r] - ps[l - 1]); } int ch(int s, int len) { int ret = get(s, min(n, s + len - 1)) + get(1, len - (n - s + 1)); return ret; } int main() { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; L(i, 1, n) { cin >> a[i]; ps[i] = ps[i - 1] + a[i]; } int len = (n + 1) / 2, ans = 0; L(i, 1, n) { vector<int> v; int f = ch(i, len), s = ch(i + 1 > n ? 1 : i + 1, len), t = (i - 1 < 1 ? n : i - 1, len); v.pb(f); v.pb(s); v.pb(t); sort(v.begin(), v.end()); ans = max(ans, max(v[0], v[1])); } cout << ans << '\n'; 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...