結果

問題 No.1231 Make a Multiple of Ten
ユーザー lloyzlloyz
提出日時 2022-02-05 09:14:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 119,584 KB
最終ジャッジ日時 2023-09-02 06:28:16
合計ジャッジ時間 3,861 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,588 KB
testcase_01 AC 70 ms
71,328 KB
testcase_02 AC 70 ms
71,356 KB
testcase_03 AC 71 ms
71,388 KB
testcase_04 AC 195 ms
92,448 KB
testcase_05 AC 157 ms
89,372 KB
testcase_06 AC 114 ms
81,860 KB
testcase_07 AC 177 ms
93,092 KB
testcase_08 AC 134 ms
85,376 KB
testcase_09 AC 106 ms
80,052 KB
testcase_10 AC 164 ms
91,312 KB
testcase_11 AC 183 ms
93,504 KB
testcase_12 AC 264 ms
116,808 KB
testcase_13 AC 277 ms
119,464 KB
testcase_14 AC 70 ms
71,468 KB
testcase_15 AC 271 ms
119,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

INF = 10**10
DP = [[-INF for _ in range(10)] for _ in range(n + 1)]
DP[0][0] = 0
for i in range(n):
    for j in range(10):
        if DP[i][j] == -INF:
            continue
        DP[i + 1][j] = max(DP[i + 1][j], DP[i][j])
        r = (j + A[i]) % 10
        DP[i + 1][r] = max(DP[i + 1][r], DP[i][j] + 1)
print(DP[n][0])
0