結果

問題 No.2639 Longest Increasing Walk
ユーザー 310icecrystal310icecrystal
提出日時 2024-02-28 15:57:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 582 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 123,384 KB
最終ジャッジ日時 2024-02-28 15:57:53
合計ジャッジ時間 8,572 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 54 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 224 ms
118,648 KB
testcase_05 AC 216 ms
121,464 KB
testcase_06 AC 251 ms
123,000 KB
testcase_07 AC 399 ms
123,128 KB
testcase_08 AC 249 ms
123,256 KB
testcase_09 AC 426 ms
123,384 KB
testcase_10 AC 527 ms
90,912 KB
testcase_11 AC 483 ms
91,128 KB
testcase_12 AC 115 ms
78,652 KB
testcase_13 AC 582 ms
106,744 KB
testcase_14 AC 333 ms
92,548 KB
testcase_15 AC 38 ms
53,460 KB
testcase_16 AC 61 ms
68,640 KB
testcase_17 AC 233 ms
92,664 KB
testcase_18 AC 409 ms
96,388 KB
testcase_19 AC 135 ms
80,512 KB
testcase_20 AC 238 ms
80,772 KB
testcase_21 AC 467 ms
90,212 KB
testcase_22 AC 200 ms
82,064 KB
testcase_23 AC 50 ms
63,944 KB
testcase_24 AC 48 ms
61,856 KB
testcase_25 AC 58 ms
66,564 KB
testcase_26 AC 37 ms
53,460 KB
testcase_27 AC 60 ms
66,552 KB
testcase_28 AC 36 ms
53,456 KB
testcase_29 AC 37 ms
53,460 KB
testcase_30 AC 37 ms
53,460 KB
testcase_31 AC 37 ms
53,460 KB
testcase_32 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]

pairs = []
for i in range(H):
    for j in range(W):
        pairs.append((A[i][j],i,j))
pairs.sort(reverse=True)

dp = [[-1]*W for _ in range(H)]
dij = [(-1,0),(1,0),(0,-1),(0,1)]
for a,i,j in pairs:
    maximum = 0
    for di,dj in dij:
        if 0 <= i+di <= H-1 and 0 <= j+dj <= W-1 and a < A[i+di][j+dj]:
            maximum = max(maximum,dp[i+di][j+dj])
    dp[i][j] = maximum+1

print(max([max(li) for li in dp]))
0