제출 #696554

#제출 시각아이디문제언어결과실행 시간메모리
696554ParsaSHacker (BOI15_hac)C++17
100 / 100
316 ms21456 KiB
// In the name of God #include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second typedef long long ll; const int N = 1e6 + 5; int n, v[N], s[N]; void solve() { cin >> n; for (int i = 0; i < n; i++) { cin >> v[i]; v[i + n] = v[i]; } int ans = 0; multiset<int> st; for (int i = 0; i < (n + 1) / 2; i++) s[(n + 1) / 2 - 1] += v[i]; for (int i = (n + 1) / 2; i < 2 * n; i++) { s[i] = s[i - 1] - v[i - (n + 1) / 2] + v[i]; } for (int i = (n + 1) / 2 - 1; i <= 2 * ((n + 1) / 2 - 1); i++) { st.insert(s[i]); } ans = *st.begin(); for (int i = (n + 1) / 2; i + (n + 1) / 2 - 1 < 2 * n; i++) { st.erase(st.find(s[i - 1])); st.insert(s[i + (n + 1) / 2 - 1]); ans = max(ans, *st.begin()); } cout << ans << '\n'; } int32_t main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); solve(); 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...