제출 #941135

#제출 시각아이디문제언어결과실행 시간메모리
941135a_l_i_r_e_z_aHacker (BOI15_hac)C++17
100 / 100
229 ms18536 KiB
// In the name of God // Hope is last to die #include <bits/stdc++.h> using namespace std; // #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2") typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pb push_back // #define int long long #define S second #define F first #define mp make_pair #define smax(x, y) (x) = max((x), (y)) #define smin(x, y) (x) = min((x), (y)) #define all(x) (x).begin(), (x).end() const int maxn = 5e5 + 5; const int inf = 1e9 + 7; int n, a[maxn], ps[maxn]; multiset<int> st; int get(int i){ int res = ps[min(n, i + (n + 1) / 2 - 1)] - ps[i - 1]; if(i + (n + 1) / 2 - 1 > n){ res += ps[i + (n + 1) / 2 - 1 - n]; } return res; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; ps[i] = ps[i - 1] + a[i]; } st.insert(get(1)); for(int i = n / 2 + 2; i <= n; i++){ st.insert(get(i)); } int ans = 0; for(int i = 1; i <= n; i++){ smax(ans, (*st.begin())); int j = i - (n - 1) / 2; if(j <= 0) j += n; st.erase(st.find(get(j))); if(i < n) st.insert(get(i + 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...