Submission #1090192

#TimeUsernameProblemLanguageResultExecution timeMemory
1090192ShaShiHacker (BOI15_hac)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> // #define int long long // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #define F first #define S second #define mp make_pair #define pb push_back #define all(x) x.begin(), x.end() #define kill(x) cout << x << "\n", exit(0); #define pii pair<int, int> #define endl "\n" using namespace std; typedef long long ll; // typedef __int128_t lll; typedef long double ld; const int MAXN = (int)1e6 + 7; const int MOD = (int)1e9 + 7; const int INF = (int)1e9 + 7; int n, m, k, tmp, t, tmp2, tmp3, tmp4, u, v, w, flag, q, ans, flag2; int arr[MAXN], ps[MAXN]; inline int go_fw(int ind, int k) { if (ind+k-1 <= n) return ps[ind+k-1]-ps[ind-1]; return ps[n]-ps[ind-1]+go_fw(1, k-(n-ind+1)); } inline int go_bk(int ind, int k) { if (ind-k+1 >= 1) return ps[ind]-ps[ind-k]; return ps[ind]+go_bk(n, k-ind); } inline int solve(int ind) { return min(go_fw(ind, (n+1)/2), go_bk(ind, (n+1)/2)); } int32_t main() { #ifdef LOCAL freopen("inp.in", "r", stdin); freopen("res.out", "w", stdout); #else ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif cin >> n; for (int i=1; i<=n; i++) { cin >> arr[i]; tmp += arr[i]; ps[i] = ps[i-1]+arr[i]; } ans = 0; for (int i=1; i<=n; i++) ans = max(ans, solve(i)); cout << ans << endl; 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...