Advertisement
anon20016

N

Nov 22nd, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int n, a[100][100];
  5.  
  6. int main() {
  7.     scanf("%d", &n);
  8.     for(int i = 0; i < n; ++i)
  9.         for(int j = 0; j <= i; ++j)
  10.             scanf("%d", &a[i][j]);
  11.     for(int i = n - 2; i >= 0; --i)
  12.         for(int j = 0; j <= i; ++j)
  13.             a[i][j] += max(a[i + 1][j], a[i + 1][j + 1]);
  14.     cout << a[0][0];
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement