fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long f[101][101];
  4. int main() {
  5. freopen("TST.INP","r",stdin);
  6. freopen("TST.OUT","w",stdout);
  7. ios::sync_with_stdio(false);
  8. cin.tie(0), cout.tie(0);
  9. int n,k; cin >> k >> n;
  10. for(int i=1;i<=k;i++) {
  11. for(int j=1;j<=n;j++) {
  12. long long x; cin >> x;
  13. if(j>=i) f[i][j]=max(f[i][j-1],f[i-1][j-1]+x);
  14. }
  15. }
  16. cout << f[k][n];
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5184KB
stdin
4 6
1 1 6 4 3 10
9 1 4 7 2 7
7 2 6 10 2 3
6 10 7 1 3 9
stdout
Standard output is empty