Advertisement
welleyth

1619. House Robber

Dec 27th, 2020
1,206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define mp make_pair
  7. #define pb push_back
  8.  
  9. /// HAHA
  10. /// They have n <= (int)1e6 in statement
  11. /// While in test they have n > 4e6
  12. /// Are they clowns?
  13.  
  14. const int N = (int)6e6; /// >(int)1e6
  15. const int INF = ((int)1e18);
  16.  
  17. int dp[N];
  18.  
  19. signed main()
  20. {
  21.     ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  22.     //freopen("input.txt","r",stdin);
  23.     //freopen("output.txt","w",stdout);
  24.  
  25.     int ans = 0;
  26.  
  27.     int n;
  28.     cin >> n;
  29.  
  30.     int mx;
  31.  
  32.     for(int i = 4 ; i < n + 4 ; i ++)
  33.     {
  34.         cin >> dp[i];
  35.         dp[i] += max(dp[i-2],dp[i-3]);
  36.         ans = max(ans,dp[i]);
  37.     }
  38.  
  39.     cout << ans;
  40.  
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement