Submission #1013055

#TimeUsernameProblemLanguageResultExecution timeMemory
1013055huyboyTriple Jump (JOI19_jumps)C++17
5 / 100
4032 ms524288 KiB
/* author : abushbandit contest : --- */ #include "bits/stdc++.h" using namespace std; #define all(x) x.begin(),x.end() #define pb push_back void solve() { int n; cin >> n; int a[n]; for(int i = 0;i < n;i++){ cin >> a[i]; } int mx[n][n] {}; for(int i = 0;i < n;i++){ mx[i][i] = a[i]; for(int j = i + 1;j < n;j++){ mx[i][j] = max(mx[i][j - 1],a[j]); } } int q; cin >> q; for(int i = 0;i < q;i++){ int l,r; cin >> l >> r; l--; r--; int ans = 0; for(int k = l;k <= r;k++){ for(int j = k + 1;j <= r;j++){ if(j + j - k > r) break; int res = a[k] + a[j]; res += mx[j + (j - k)][r]; ans = max(ans,res); } } cout << ans << "\n"; } } signed main() { ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); int t = 1; //~ cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...