Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_DEPRECATE
- #include <iostream>
- #include <vector>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #define ull unsigned long long
- #define ll long long
- using namespace std;
- ll d[101];
- ll a[101];
- int main() {
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- for (int i = 1; i <= n; i++) {
- cin >> a[i];
- d[i] = 0;
- }
- d[0] = 0;
- d[1] = a[1];
- for (int i = 2; i <= n; i++) {
- d[i] = a[i] + max(d[i - 1], d[i - 2]);
- }
- cout << d[n];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement