結果

問題 No.1231 Make a Multiple of Ten
コンテスト
ユーザー hir355
提出日時 2020-09-18 21:33:14
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 1,498 ms / 2,000 ms
+ 773µs
コード長 398 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 32,836 KB
最終ジャッジ日時 2026-10-12 16:51:50
合計ジャッジ時間 10,126 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
t = [0] * 10
dp = [[-1] * 10 for _ in range(2)]
dp[0][0] = 0
for i in range(n):
    p, q = i % 2, (i + 1) % 2
    for k in range(10):
        if dp[p][k] >= 0:
            dp[q][(k + a[i]) % 10] = max(dp[q][(k + a[i]) % 10], dp[p][k] + 1)
        dp[q][k] = max(dp[q][k], dp[p][k])
print(max(dp[0][0], dp[1][0]))
0