제출 #944927

#제출 시각아이디문제언어결과실행 시간메모리
944927Xiaoyang3단 점프 (JOI19_jumps)C++17
5 / 100
3 ms604 KiB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
 
#define fi first 
#define se second 
#define pll pair<ll,ll>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl;
#define MP make_pair
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()
#define endl "\n"
const ll inf=1e18;
ll lowbit(ll x){return x&(-x);}

const ll maxn=1111;
ll a[maxn];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;cin>>n;
	rep(i,1,n+1)cin>>a[i];
	ll q;cin>>q;
	while(q--){
		ll l,r;cin>>l>>r;
		ll mx=0;
		rep(i,l,r+1){
			rep(j,i+1,r+1){
				rep(k,j+1,r+1){
					if(k-j<j-i)continue;
					mx=max(mx,a[i]+a[j]+a[k]);
				}
			}
		}
		cout<<mx<<endl;
	}
	return 0;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...