結果

問題 No.1231 Make a Multiple of Ten
ユーザー shotoyooshotoyoo
提出日時 2020-09-19 13:49:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 107,276 KB
最終ジャッジ日時 2024-06-23 13:56:21
合計ジャッジ時間 2,218 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
inf = 10**15
dp = [-inf]*10
dp[0] = 0
for i in range(n):
    nl = [inf]*10
    nl[0] = 0
    for j in range(10):
        nl[(j+a[i])%10] = max(dp[(j+a[i])%10], dp[j] + 1)
    dp = nl
#     print(dp)
if dp[0]>-inf:
    ans = dp[0]
else:
    ans = 0
print(ans)
0