結果

問題 No.1231 Make a Multiple of Ten
ユーザー yatsurugiyatsurugi
提出日時 2020-09-24 14:21:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 354 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 10,604 KB
実行使用メモリ 30,500 KB
最終ジャッジ日時 2023-09-10 13:26:49
合計ジャッジ時間 14,062 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,784 KB
testcase_01 AC 16 ms
7,940 KB
testcase_02 AC 17 ms
7,736 KB
testcase_03 AC 17 ms
7,816 KB
testcase_04 AC 1,028 ms
18,092 KB
testcase_05 AC 914 ms
16,688 KB
testcase_06 AC 363 ms
11,344 KB
testcase_07 AC 1,062 ms
18,528 KB
testcase_08 AC 627 ms
13,936 KB
testcase_09 AC 217 ms
9,892 KB
testcase_10 AC 950 ms
17,204 KB
testcase_11 AC 1,156 ms
19,400 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 16 ms
7,772 KB
testcase_15 TLE -
権限があれば一括ダウンロードができます

ソースコード

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