Submission #939329

#TimeUsernameProblemLanguageResultExecution timeMemory
939329Amirreza_FakhriHacker (BOI15_hac)C++17
20 / 100
299 ms15968 KiB
// In the name of the God #include <bits/stdc++.h> #define ll long long #define int long long #define pb push_back #define F first #define S second #define mp make_pair #define pii pair <int, int> #define smin(x, y) (x) = min((x), (y)) #define smax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(), (x).end() using namespace std; // #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2") const int inf = 1e9+7; const int mod = 998244353; const int maxn = 5e5+5; int n, v[maxn]; multiset <int> st; int g(int i, int x = (n+1)/2) { if (i+x-1 < n) { // if (i == 1) cout << "HI\n" << ' ' << v[i+x-1] << ' ' << (i-1 >= 0 ? v[i-1] : 0) << '\n'; return v[i+x-1]-(i-1 >= 0 ? v[i-1] : 0); } int j = (i+x-1)%n; return v[j]+v[n-1]-(i-1 >= 0 ? v[i-1] : 0); } int p(int i, int x = (n+1)/2) { i = (i-x+1+3*n)%n; return g(i); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> v[i]; if (i) v[i] += v[i-1]; } for (int i = 0; i < (n+1)/2; i++) st.insert(g(i)); int ans = 0; for (int i = 0; i < n; i++) { int j = ((n+1)/2-1+i)%n; smax(ans, *st.begin()); st.erase(p(j)); st.insert(g((j+1)%n)); } 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...