Submission
Status:
[PPPP-SSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: nik121416
Problemset: อัศวินขี่ม้าขาว
Language: cpp
Time: 0.006 second
Submitted On: 2026-03-20 09:37:00
#include<bits/stdc++.h>
using namespace std;
int n,m;
bool f(int a,int b,int hp,vector<vector<int>> &num){
if(a == n-1 && b == m-1){
hp+=num[a][b];
if(hp <= 0){
return false;
}
else{
return true;
}
}
if(a > n-1 || b > m-1) return false;
hp += num[a][b];
if(hp <= 0 )return false;
bool A = f(a+1,b,hp,num);
bool B = f(a,b+1,hp,num);
return A || B;
}
int main(){
cin >> n >> m;
vector<vector<int>> mp(n,vector<int>(m));
for(int i = 0 ;i < n;i++){
for(int j = 0;j < m;j++){
cin >> mp[i][j];
}
}
for(int i = 0 ;i < 1e6;i++){
bool A = f(0,0,i,mp);
if(A){
cout << i;
break;
}
}
}