Submission #146003

#TimeUsernameProblemLanguageResultExecution timeMemory
146003fedoseevtimofeyTriple Jump (JOI19_jumps)C++14
5 / 100
4091 ms2808 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <int> A(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;
		int ans = 0;
		for (int a = l; a <= r; ++a) {
			for (int b = a + 1; b <= r; ++b) {
				for (int c = b + b - a; c <= r; ++c) {
					ans = max(ans, A[a] + A[b] + A[c]);
				}
			}
		}
		cout << ans << '\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...