Submission #1010567

#TimeUsernameProblemLanguageResultExecution timeMemory
1010567danikoynovTriple Jump (JOI19_jumps)C++14
0 / 100
2 ms348 KiB
#include<bits/stdc++.h> #define endl '\n' const int MAX_N = 110; int n, q, a[MAX_N]; void input() { std::cin >> n; for (int i = 1; i <= n; i ++) std::cin >> a[i]; } void single_query(int l, int r) { int res = 0, mx = 0; for (int i = l; i <= r; i ++) mx = std::max(mx, a[i]); for (int i = l; i <= r; i ++) for (int f = i + 1; f <= r; f ++) for (int j = f + (f - i); j <= r; j ++) { if (a[i] != mx && a[f] != mx && a[j] != mx) continue; res = std::max(res, a[i] + a[f] + a[j]); } std::cout << res << endl; } void answer_queries() { std::cin >> q; for (int i = 1; i <= q; i ++) { int l, r; std::cin >> l >> r; single_query(l, r); } } void solve() { input(); answer_queries(); } int main() { 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...