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 fi first
#define se second
#define ll long long
using namespace std ;
const int N = 5e5 ;
int n, q, d[N + 1] ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n ;
for(int i = 1 ; i <= n ; i++)
cin >> d[i] ;
cin >> q ;
if(n <= 100 && q <= 100)
{
while(q--)
{
int l, r, ans = 0 ;
cin >> l >> r ;
for(int b = l + 1 ; b < r ; b++)
for(int a = l ; a < b ; a++)
for(int c = b + (b - a) ; c <= r ; c++)
ans = max(ans, d[a] + d[b] + d[c]) ;
cout << ans << '\n' ;
}
return 0 ;
}
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... |