結果

問題 No.1231 Make a Multiple of Ten
ユーザー MineMine
提出日時 2020-09-22 16:31:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 249 ms / 2,000 ms
コード長 361 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 115,836 KB
最終ジャッジ日時 2023-09-08 12:46:22
合計ジャッジ時間 3,871 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,508 KB
testcase_01 AC 91 ms
71,496 KB
testcase_02 AC 90 ms
71,668 KB
testcase_03 AC 91 ms
71,776 KB
testcase_04 AC 190 ms
101,272 KB
testcase_05 AC 165 ms
99,952 KB
testcase_06 AC 122 ms
80,984 KB
testcase_07 AC 175 ms
102,716 KB
testcase_08 AC 148 ms
93,964 KB
testcase_09 AC 121 ms
78,664 KB
testcase_10 AC 172 ms
101,524 KB
testcase_11 AC 179 ms
102,456 KB
testcase_12 AC 248 ms
115,836 KB
testcase_13 AC 246 ms
115,452 KB
testcase_14 AC 93 ms
71,424 KB
testcase_15 AC 249 ms
115,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
dp = [[0]*10 for i in range(n+1)]

for i in range(n):
    dp[i+1][a[i]%10] += 1
    for g in range(10):
        dp[i+1][g%10] = max(dp[i][g], dp[i+1][g%10])
        if dp[i][g] != 0:
            dp[i+1][(g+a[i])%10] = max(dp[i][g]+1, dp[i+1][(g+a[i])%10])

print(dp[n][0])
0