이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
#define uwu ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize("Ofast")
const int INF = 1e9 + 7;
const long long INF2 = 1e17;
int main(void) {
uwu
int n; cin >> n;
vector <long long> v(n);
ffor(n) cin >> v[i];
vector <tuple <int, int, int, long long>> jumps;
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
for(int delta = j - i, k = j + delta; k < n; k++) {
jumps.push_back(tuple(i, j, k, v[i] + v[j] + v[k]));
}
}
}
int q; cin >> q;
ffor(q) {
int a, b; cin >> a >> b;
a--; b--;
long long current = 0;
for(int j = 0; j < (int)jumps.size(); j++) {
if (get<0>(jumps[j]) >= a && get<2>(jumps[j]) <= b) {
current = max(current, get<3>(jumps[j]));
}
}
cout << current << '\n';
}
}
/*
C:\Users\kenne\OneDrive\Desktop\competitive_programming\main.cpp
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |