結果

問題 No.2639 Longest Increasing Walk
ユーザー titiatitia
提出日時 2024-02-21 02:58:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,212 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 51,376 KB
最終ジャッジ日時 2024-02-21 02:58:47
合計ジャッジ時間 14,664 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
9,984 KB
testcase_01 AC 29 ms
9,984 KB
testcase_02 AC 29 ms
9,984 KB
testcase_03 AC 29 ms
9,984 KB
testcase_04 AC 828 ms
43,776 KB
testcase_05 AC 1,146 ms
51,376 KB
testcase_06 AC 1,071 ms
50,680 KB
testcase_07 AC 1,207 ms
50,432 KB
testcase_08 AC 1,130 ms
50,992 KB
testcase_09 AC 1,212 ms
51,220 KB
testcase_10 AC 802 ms
29,088 KB
testcase_11 AC 732 ms
28,048 KB
testcase_12 AC 120 ms
12,672 KB
testcase_13 AC 890 ms
31,676 KB
testcase_14 AC 482 ms
21,180 KB
testcase_15 AC 30 ms
9,984 KB
testcase_16 AC 41 ms
10,368 KB
testcase_17 AC 473 ms
22,772 KB
testcase_18 AC 571 ms
23,240 KB
testcase_19 AC 161 ms
13,696 KB
testcase_20 AC 391 ms
18,144 KB
testcase_21 AC 707 ms
28,340 KB
testcase_22 AC 250 ms
15,872 KB
testcase_23 AC 33 ms
10,112 KB
testcase_24 AC 32 ms
10,112 KB
testcase_25 AC 35 ms
10,112 KB
testcase_26 AC 29 ms
9,984 KB
testcase_27 AC 37 ms
10,240 KB
testcase_28 AC 30 ms
9,984 KB
testcase_29 AC 31 ms
9,984 KB
testcase_30 AC 30 ms
9,984 KB
testcase_31 AC 29 ms
9,984 KB
testcase_32 AC 30 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter

H,W=map(int,input().split())

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

LIST=[]
for i in range(H):
    for j in range(W):
        LIST.append((A[i][j],i,j))

LIST.sort(key=itemgetter(0),reverse=True)

DP=[[1]*W for i in range(H)]

for w,i,j in LIST:
    for x,y in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
        if 0<=x<H and 0<=y<W:
            if A[x][y]>A[i][j]:
                DP[i][j]=max(DP[i][j],DP[x][y]+1)

ANS=0
for i in range(H):
    for j in range(W):
        ANS=max(ANS,DP[i][j])

print(ANS)
0