結果
| 問題 |
No.2639 Longest Increasing Walk
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-19 22:30:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 450 ms / 2,000 ms |
| コード長 | 443 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 82,332 KB |
| 実行使用メモリ | 122,408 KB |
| 最終ジャッジ日時 | 2024-09-29 02:23:10 |
| 合計ジャッジ時間 | 6,727 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
H,W=map(int,input().split())
L=[list(map(int,input().split())) for _ in range(H)]
q=[]
for h in range(H):
for w in range(W):
q.append((L[h][w],h,w))
dp=[[1]*W for _ in range(H)]
q.sort()
dhw=[(1,0),(-1,0),(0,1),(0,-1)]
ans=1
for x,h,w in q:
for dh,dw in dhw:
if 0<=h+dh<H and 0<=w+dw<W and L[h][w]<L[h+dh][w+dw]:
dp[h+dh][w+dw]=max(dp[h+dh][w+dw],dp[h][w]+1)
if ans<dp[h+dh][w+dw]:
ans=dp[h+dh][w+dw]
print(ans)