Submission #1248066

#TimeUsernameProblemLanguageResultExecution timeMemory
1248066chikien2009Hacker (BOI15_hac)C++20
20 / 100
0 ms472 KiB
#include <bits/stdc++.h> using namespace std; void setup() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, a[4001]; long long pre[4001], res; priority_queue<pair<long long, int>> pq; int main() { setup(); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; a[i + n] = a[i]; } for (int i = 1; i <= 2 * n; ++i) { pre[i] = a[i] + pre[i - 1]; } for (int i = 1, j = 1; i <= n; ++i) { while (j + n / 2 < i + n) { pq.push({pre[j + n / 2] - pre[j], j}); j++; } while (!pq.empty() && pq.top().second < i) { pq.pop(); } res = max(res, pre[n] - pq.top().first); } cout << res; 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...