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>
using namespace std;
#define int long long
const int maxn = 1e6 + 4;
int a[maxn] , n , m;
void nhap()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1 ; i <= n ; i ++)
cin >> a[i];
cin >> m;
}
void xl1(int l , int r)
{
int ans = 0;
for (int i = l ; i <= r - 2 ; i ++)
{
for (int j = i + 1 ; j <= r - 1 ; j ++)
{
for (int k = j + (j - i) ; k <= r ; k ++)
{
ans = max(ans , a[i] + a[j] + a[k]);
}
}
}
cout << ans << '\n';
}
void Sub1()
{
for (int i = 1 ; i <= m ; i ++)
{
int l , r;
cin >> l >> r;
xl1(l , r);
}
}
signed main()
{
nhap();
if (n <= 100 && m <= 100)
Sub1();
}
# | 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... |