This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
for (int i = l; i <= r; i ++)
for (int f = i + 1; f <= r; f ++)
for (int j = f + (f - i); j <= r; j ++)
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 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... |