Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <string>
- #include <set>
- #include <map>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main()
- {
- long n, m;
- cin >> n >> m;
- vector<vector<long> > a(n + 1, vector<long> (m + 1, 0));
- for(long i = 1; i <= n; i++) {
- for(long j = 1; j <= m; j++) {
- cin >> a[i][j];
- }
- }
- for(long i = 1; i <= n; i++) {
- for(long j = 1; j <= m; j++) {
- a[i][j] += max(a[i][j - 1], max(a[i - 1][j - 1], a[i - 1][j]));
- }
- }
- cout << a[n][m];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement