結果

問題 No.1231 Make a Multiple of Ten
ユーザー shotoyooshotoyoo
提出日時 2020-09-19 13:49:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 100,632 KB
最終ジャッジ日時 2023-09-05 18:28:07
合計ジャッジ時間 3,166 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,204 KB
testcase_01 AC 80 ms
71,208 KB
testcase_02 AC 76 ms
71,388 KB
testcase_03 AC 76 ms
71,624 KB
testcase_04 AC 126 ms
90,292 KB
testcase_05 AC 121 ms
88,436 KB
testcase_06 AC 99 ms
80,092 KB
testcase_07 AC 131 ms
92,192 KB
testcase_08 AC 106 ms
83,384 KB
testcase_09 AC 94 ms
77,720 KB
testcase_10 AC 124 ms
90,004 KB
testcase_11 AC 131 ms
92,252 KB
testcase_12 AC 174 ms
100,332 KB
testcase_13 AC 179 ms
100,564 KB
testcase_14 AC 74 ms
71,096 KB
testcase_15 AC 180 ms
100,632 KB
権限があれば一括ダウンロードができます

ソースコード

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