Submission #773582

# Submission time Handle Problem Language Result Execution time Memory
773582 2023-07-05T06:58:32 Z gagik_2007 Triple Jump (JOI19_jumps) C++17
0 / 100
24 ms 3540 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define ff first
#define ss second

ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=5007;
ll n,m,k;
ll dp[N][N]; // l-ic r vor vercnenq maqsimumy
ll pf[N][N]; // l-ic enq sksum, kamayakan r'-i hamar minchev r
ll res[N][N]; // kamayakan l'-ic kamayakan r'
ll a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll ans=0;
    for(int l=n;l>=1;l--){
        for(int r=l+2;r<=n;r++){
            int mid=(l+r)/2;
            dp[l][r]=max(dp[l][r-1],a[l]+a[r]+a[mid]);

            pf[l][r]=max(pf[l][r-1],dp[l][r]);

            res[l][r]=max(res[l+1][r],pf[l][r]);

            ans=max(ans,res[l][r]);
        }
    }
    cin>>m;
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        cout<<res[l][r]<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 2 ms 1620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 2 ms 1620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 3540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 2 ms 1620 KB Output isn't correct
3 Halted 0 ms 0 KB -