제출 #1009668

#제출 시각아이디문제언어결과실행 시간메모리
1009668MarwenElarbiTriple Jump (JOI19_jumps)C++17
19 / 100
729 ms524288 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long #define fi first #define se second #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <class T> using Tree = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; const int nax=1e3+5; signed main(){ iostream::sync_with_stdio(false); cin.tie(0); int n; cin>>n; int tab[n]; int dp[n][n]; memset(dp,0,sizeof dp); for (int i = 0; i < n; ++i) { cin>>tab[i]; } for (int i = n-3; i >= 0; i--) { int mx=tab[i+1]; for (int j = i+2; j < n; ++j) { dp[i][j]=max(dp[i][j],max(dp[i+1][j],dp[i][j-1])); dp[i][j]=max(dp[i][j],tab[i]+tab[j]+mx); //cout <<i<<" "<<j<<" "<<dp[i][j]<<endl; mx=max(mx,tab[i+(j-i+1)/2]); } } int q; cin>>q; while(q--){ int x,y; cin>>x>>y; x--;y--; cout <<dp[x][y]<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...