Submission #1036032

#TimeUsernameProblemLanguageResultExecution timeMemory
1036032May27_thTriple Jump (JOI19_jumps)C++17
0 / 100
4091 ms1112 KiB
#include<bits/stdc++.h> using namespace std; #define i64 long long #define mp make_pair #define pb push_back #define all(x) (x).begin(), (x).end() void Solve(void) { int N; cin >> N; vector<int> a(N + 1); for (int i = 1; i <= N; i ++) cin >> a[i]; int Q; cin >> Q; while (Q --) { int L, R; cin >> L >> R; int gap = (R - L + 1); i64 ans = 0; for (int mask = 0; mask < (1 << gap); mask ++) { i64 cur = 0; int d = -1, prev = -1, cnt = 0; bool works = true; for (int b = 0; b < gap; b ++) { if (mask >> b & 1) { cnt ++; cur = cur + a[b + L]; if (prev == -1) prev = b; else if (d == -1) { d = b - prev; prev = b; } else if (d > b - prev) { works = false; break; } } } if (cnt == 3 && works) { ans = max(ans, cur); } } cout << ans << "\n"; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10); int Tests = 1; // cin >> Tests; while (Tests --) { Solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...