# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
854934 | vjudge1 | Triple Jump (JOI19_jumps) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define endl '\n'
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
const int mod = 1e9 + 7;
const int N = 200 005;
const ll inf = 1e18;
int mx[N];
int suf[N];
int a[N];
int ans[N];
int dp[N];
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n;
cin >> n;
for (int i=1;i<=n;i++){
cin >> a[i];
mx[i] = max(a[i], mx[i-1]);
}
dp[2] = a[1]+a[2];
for (int j=3;j<=n;j++){
dp[j] = max(dp[j-1], a[j]+mx[j-1]);
}