제출 #632026

#제출 시각아이디문제언어결과실행 시간메모리
632026BhavayGoyalHacker (BOI15_hac)C++14
0 / 100
342 ms24228 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define ll long long #define ld long double #define ar array #define vi vector<int> #define vii vector<vector<int>> #define pii pair<int, int> #define pb push_back #define all(x) x.begin(), x.end() #define f first #define s second #define endl "\n" const int MOD = 1e9+7; const int inf = 1e9; const ll linf = 1e18; const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1}; const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1}; // -------------------------------------------------- Main Code -------------------------------------------------- void sol() { int n; cin >> n; int mid = (n+1)/2; ll arr[2*n]; for (int i = 0; i < n; i++) {cin >> arr[i]; arr[i+n] = arr[i];} for (int i = 1; i < 2*n; i++) arr[i] += arr[i-1]; multiset<ll> st; queue<ll> q; for (int i = mid-1; i < n-1; i++) { int pSum = arr[i]; if (i >= mid) pSum -= arr[i-mid]; st.insert(pSum); q.push(pSum);} ll ans = *st.begin(); for (int i = n-1; i < 2*n; i++) { st.erase(q.front()); q.pop(); int pSum = arr[i] - arr[i-mid]; st.insert(pSum); q.push(pSum); ans = max(ans, *st.begin()); } cout << ans << endl; } int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while (t--) { sol(); } 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...