Submission

Status:

[PPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: meme_boi2

Problemset: อัศวินขี่ม้าขาว

Language: cpp

Time: 0.056 second

Submitted On: 2026-03-19 20:42:51

#include <bits/stdc++.h>
using namespace std;
int mat[1002][1002];
vector<vector<int>> dp(1002,vector<int> (1002,2e9));
int32_t main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    int m, n;
    cin >> m  >> n;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            cin >> mat[i][j];
        }
    }
   // dp[1][1] = (mat[1][1] < 0 ? 1 - mat[1][1] : 1) - mat[1][1];
   dp[m+1][n] = dp[n][m+1] = 1;
    for(int i = m; i >= 1; i--){
        for(int j = n; j >= 1; j--){
            
            dp[i][j] = max(1,min(dp[i+1][j],dp[i][j+1])- mat[i][j]) ;
        //    cout << dp[i][j] << ' ';
        }
      //  cout << '\n';
    }
    cout << dp[1][1];
}
/*
3 3 
-2 -3 3
-5 -10 1 
10 30 -5

2 3
3 -20 30
-3 4 0

3 3
3 0 -3
-3 -2 -2
3 1 -3

c2_st65_knight

cd "c:\Users\RICOH-NB110\Desktop\Computer Programing\gchan\" ; if ($?) { g++ c2_st65_knight.cpp -o c2_st65_knight } ; if ($?) { .\c2_st65_knight}
*/