Submission #1139280

#TimeUsernameProblemLanguageResultExecution timeMemory
1139280buzdiHacker (BOI15_hac)C++17
40 / 100
1092 ms1860 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int NMAX = 5e5; const int INF = 2e9; int n, k; int s, max_answer; int answer[NMAX + 1]; int a[2 * NMAX + 1]; int sp[2 * NMAX + 1]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; a[n + i] = a[i]; } k = n / 2 + n % 2; for(int i = 1; i <= 2 * n; i++) { sp[i] = sp[i - 1] + a[i]; } for(int i = 1; i <= n; i++) { answer[i] = INF; } for(int i = k; i - k + 1 <= n; i++) { int s_here = sp[i] - sp[i - k]; for(int j = i - k + 1; j <= i; j++) { int pos = (j > n ? j - n : j); answer[pos] = min(answer[pos], s_here); } } for(int i = 1; i <= n; i++) { max_answer = max(max_answer, answer[i]); } cout << max_answer << '\n'; return 0; } /* 1 2 3 4 5 1 2 3 4 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...