結果

問題 No.1231 Make a Multiple of Ten
ユーザー Akijin_007Akijin_007
提出日時 2023-02-04 19:15:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 1,048 ms
コンパイル使用メモリ 87,344 KB
実行使用メモリ 100,412 KB
最終ジャッジ日時 2023-09-16 15:45:42
合計ジャッジ時間 5,050 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,332 KB
testcase_01 AC 69 ms
71,384 KB
testcase_02 AC 69 ms
71,268 KB
testcase_03 AC 69 ms
71,280 KB
testcase_04 AC 99 ms
89,588 KB
testcase_05 AC 89 ms
87,648 KB
testcase_06 AC 81 ms
79,176 KB
testcase_07 AC 99 ms
91,164 KB
testcase_08 AC 84 ms
82,472 KB
testcase_09 AC 77 ms
77,116 KB
testcase_10 AC 89 ms
89,300 KB
testcase_11 AC 92 ms
91,220 KB
testcase_12 AC 123 ms
100,204 KB
testcase_13 AC 124 ms
100,412 KB
testcase_14 AC 69 ms
71,272 KB
testcase_15 AC 124 ms
100,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

m = [0] * 10
s = sum(A) % 10
for i in range(N):
    m[A[i]%10] += 1

dp = [N] * 10

dp[0] = 0
ndp = list(dp)
for i in range(1, 10):
    for j in range(min(m[i]+1, 10)):
        for k in range(10):
            t = (k + i*j)%10
            ndp[t] = min(ndp[t], dp[k]+j)
    dp = list(ndp)
    # print(dp)

print(N - dp[s])
0