제출 #742595

#제출 시각아이디문제언어결과실행 시간메모리
742595myrcellaTriple Jump (JOI19_jumps)C++17
19 / 100
517 ms289216 KiB
//by szh #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} const int maxn = 5e3+10; int n; int a[maxn]; int dp[maxn][maxn],ans[maxn][maxn]; int mx[maxn][maxn]; int main() { // freopen("input.txt","r",stdin); std::ios::sync_with_stdio(false);cin.tie(0); cin>>n; rep(i,1,n+1) cin>>a[i]; rep(i,1,n+1) { mx[i][0] = 0; for (int j=1;i-j-j>0;j++) mx[i][j] = max(mx[i][j-1], a[i]+a[i-j]+a[i-j-j]); } rep(i,1,n-1) { ans[i][i+2] = dp[i][i+2] = a[i]+a[i+1]+a[i+2]; rep(j,i+3,n+1) { dp[i][j] = dp[i][j-1] + a[j] - a[j-1]; dp[i][j] = max(dp[i][j],mx[j][(j-i)/2]); ans[i][j] = max(ans[i][j-1],dp[i][j]); } } int _;cin>>_; while (_--) { int x,y;cin>>x>>y; cout<<ans[x][y]<<"\n"; } 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...