Submission #833117

#TimeUsernameProblemLanguageResultExecution timeMemory
833117PurpleCrayonTriple Jump (JOI19_jumps)C++17
5 / 100
4011 ms1652 KiB
#include <bits/stdc++.h> using namespace std; #define sz(v) int(v.size()) #define ar array typedef long long ll; const int N = 5e5+10, INF = 1e9+10; int n, q, a[N]; void solve() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } int q; cin >> q; while (q--) { int l, r; cin >> l >> r, --l, --r; ll ans = 0; for (int i = l; i <= r; i++) { for (int j = i+1; j <= r; j++) { for (int k = j+1; k <= r; k++) { if (k - j >= j - i) { ans = max(ans, (long long) a[i] + a[j] + a[k]); } } } } cout << ans << '\n'; } } int main() { ios::sync_with_stdio(false); cin.tie(0); 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...