結果

問題 No.127 門松もどき
ユーザー 👑 colognecologne
提出日時 2022-03-02 16:45:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 698 ms / 5,000 ms
コード長 582 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 147,868 KB
最終ジャッジ日時 2023-09-23 09:11:15
合計ジャッジ時間 10,736 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,868 KB
testcase_01 AC 75 ms
71,108 KB
testcase_02 AC 76 ms
70,852 KB
testcase_03 AC 79 ms
71,016 KB
testcase_04 AC 698 ms
135,984 KB
testcase_05 AC 77 ms
71,212 KB
testcase_06 AC 127 ms
76,072 KB
testcase_07 AC 86 ms
75,676 KB
testcase_08 AC 80 ms
75,144 KB
testcase_09 AC 78 ms
74,676 KB
testcase_10 AC 79 ms
71,208 KB
testcase_11 AC 91 ms
75,864 KB
testcase_12 AC 346 ms
113,676 KB
testcase_13 AC 480 ms
126,676 KB
testcase_14 AC 457 ms
113,196 KB
testcase_15 AC 619 ms
135,980 KB
testcase_16 AC 425 ms
113,080 KB
testcase_17 AC 397 ms
128,560 KB
testcase_18 AC 351 ms
119,472 KB
testcase_19 AC 247 ms
102,820 KB
testcase_20 AC 242 ms
103,772 KB
testcase_21 AC 170 ms
89,916 KB
testcase_22 AC 634 ms
147,624 KB
testcase_23 AC 585 ms
147,868 KB
testcase_24 AC 509 ms
131,320 KB
testcase_25 AC 674 ms
136,196 KB
testcase_26 AC 397 ms
108,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    *A, = map(int, input().split())
    DP = [[0]*N for i in range(N)]
    order = sorted(range(N), key=lambda x: A[x], reverse=True)

    for i in order:
        DP[i][i] = 1
        for j in range(i-1, -1, -1):
            DP[i][j] = DP[i][j+1]
            if A[i] < A[j]:
                DP[i][j] = max(DP[i][j], DP[j][i-1]+1)
        for j in range(i+1, N):
            DP[i][j] = DP[i][j-1]
            if A[i] < A[j]:
                DP[i][j] = max(DP[i][j], DP[j][i+1]+1)

    print(max(map(max, DP)))


if __name__ == '__main__':
    main()
0