結果

問題 No.1231 Make a Multiple of Ten
ユーザー yatsurugiyatsurugi
提出日時 2020-09-24 14:22:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 497 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 100,416 KB
最終ジャッジ日時 2023-09-10 13:27:00
合計ジャッジ時間 3,403 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,672 KB
testcase_01 AC 70 ms
70,664 KB
testcase_02 AC 71 ms
70,912 KB
testcase_03 AC 71 ms
70,724 KB
testcase_04 AC 128 ms
89,620 KB
testcase_05 AC 116 ms
87,748 KB
testcase_06 AC 95 ms
79,584 KB
testcase_07 AC 125 ms
91,504 KB
testcase_08 AC 103 ms
82,872 KB
testcase_09 AC 88 ms
77,424 KB
testcase_10 AC 118 ms
89,312 KB
testcase_11 AC 129 ms
91,772 KB
testcase_12 AC 178 ms
100,328 KB
testcase_13 AC 180 ms
100,200 KB
testcase_14 AC 71 ms
70,912 KB
testcase_15 AC 179 ms
100,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

# dp[mod] = 最大の枚数
dp = [-1] * 10
dp[0] = 0
for a in A:
    dp_tmp = [-1] * 10
    for i in range(10):
        if dp[i] == -1:
            continue
        dp_tmp[i] = max(dp[i], dp_tmp[i])
        n = (i + a) % 10
        dp_tmp[n] = max(dp[i] + 1, dp_tmp[n])
    dp = dp_tmp

print(dp[0])
0