結果
問題 |
No.1948 足し算するだけのパズルゲーム(1)
|
ユーザー |
![]() |
提出日時 | 2022-04-02 20:22:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 207 ms / 2,000 ms |
コード長 | 920 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 101,736 KB |
最終ジャッジ日時 | 2024-06-26 20:41:17 |
合計ジャッジ時間 | 5,010 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
H,W = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(H)] DP = [[[0]*2 for _ in range(W)]for _ in range(H)] DP[0][0][0]=A[0][0] for h in range(H): for w in range(W): if h+1<H and DP[h][w][0]>A[h+1][w]: DP[h+1][w][0]=max(DP[h+1][w][0],DP[h][w][0]+A[h+1][w]) if w+1<W and DP[h][w][0]>A[h][w+1]: DP[h][w+1][0]=max(DP[h][w+1][0],DP[h][w][0]+A[h][w+1]) if h+1<H and DP[h][w][1]>A[h+1][w]: DP[h+1][w][1]=max(DP[h+1][w][1],DP[h][w][1]+A[h+1][w]) if w+1<W and DP[h][w][1]>A[h][w+1]: DP[h][w+1][1]=max(DP[h][w+1][1],DP[h][w][1]+A[h][w+1]) if h+1<H and DP[h][w][0]<=A[h+1][w]: DP[h+1][w][1]=max(DP[h+1][w][1],DP[h][w][0]) if w+1<W and DP[h][w][0]<=A[h][w+1]: DP[h][w+1][1]=max(DP[h][w+1][1],DP[h][w][0]) if max(DP[H-1][W-1])>A[H-1][W-1]: print('Yes') else: print('No')