結果

問題 No.1231 Make a Multiple of Ten
ユーザー yasshi_noyasshi_no
提出日時 2020-09-25 16:39:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 312 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 1,331 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 123,748 KB
最終ジャッジ日時 2023-09-10 14:33:09
合計ジャッジ時間 6,262 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
77,736 KB
testcase_01 AC 147 ms
77,648 KB
testcase_02 AC 154 ms
77,804 KB
testcase_03 AC 151 ms
77,688 KB
testcase_04 AC 239 ms
99,660 KB
testcase_05 AC 220 ms
92,820 KB
testcase_06 AC 185 ms
85,108 KB
testcase_07 AC 237 ms
100,204 KB
testcase_08 AC 203 ms
88,580 KB
testcase_09 AC 172 ms
81,288 KB
testcase_10 AC 229 ms
93,712 KB
testcase_11 AC 243 ms
101,588 KB
testcase_12 AC 305 ms
121,372 KB
testcase_13 AC 312 ms
123,744 KB
testcase_14 AC 151 ms
77,728 KB
testcase_15 AC 310 ms
123,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    
    n = I()
    a = [0] + LI()

    dp = [[n for _ in range(10)] for _ in range(n+1)]
    dp[0][0] = 0

    for i in range(1,n+1):
        for j in range(10):
            dp[i][j] = min(dp[i-1][j], dp[i-1][(j-a[i])%10]+1)

    sm = sum(a)
    ans = n - dp[n][sm%10]
    print(ans)



main()
0