Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define mp make_pair
- #define pb push_back
- /// HAHA
- /// They have n <= (int)1e6 in statement
- /// While in test they have n > 4e6
- /// Are they clowns?
- const int N = (int)6e6; /// >(int)1e6
- const int INF = ((int)1e18);
- int dp[N];
- signed main()
- {
- ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- int ans = 0;
- int n;
- cin >> n;
- int mx;
- for(int i = 4 ; i < n + 4 ; i ++)
- {
- cin >> dp[i];
- dp[i] += max(dp[i-2],dp[i-3]);
- ans = max(ans,dp[i]);
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement