#include using namespace std; using ll=long long; using pll=pair; using tll=tuple; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template void chmin(T &a,T b){ if(a>b){ a=b; } } template void chmax(T &a,T b){ if(a> h >> w; h-=2; vector> a(h,vector(w)); rep(i,h){ rep(j,w){ cin >> a[i][j]; } } vector> dp(h,vector(w,INF)); rep(i,h){ if(a[i][0]==-1) continue; dp[i][0]=a[i][0]; } for(ll j=1;j