Submission #1090772

#TimeUsernameProblemLanguageResultExecution timeMemory
1090772ShaShiHacker (BOI15_hac)C++17
40 / 100
1074 ms1628 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], dp[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 solve(int ind) { int j = ind, res = INF; for (int i=0; i<(n+1)/2; i++) { res = min(res, dp[j]); j--; if (!j) j = n; } return res; } 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]; } for (int i=1; i<=n; i++) dp[i] = go_fw(i, (n+1)/2); 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...