結果

問題 No.1231 Make a Multiple of Ten
ユーザー zer0zer0
提出日時 2020-09-21 15:40:38
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 86,648 KB
実行使用メモリ 120,060 KB
最終ジャッジ日時 2023-09-06 17:10:31
合計ジャッジ時間 4,766 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,108 KB
testcase_01 AC 71 ms
71,272 KB
testcase_02 AC 70 ms
71,332 KB
testcase_03 AC 69 ms
71,016 KB
testcase_04 AC 161 ms
93,916 KB
testcase_05 AC 139 ms
92,708 KB
testcase_06 AC 111 ms
85,284 KB
testcase_07 AC 155 ms
95,300 KB
testcase_08 AC 124 ms
90,152 KB
testcase_09 AC 100 ms
80,932 KB
testcase_10 AC 140 ms
93,908 KB
testcase_11 AC 163 ms
95,224 KB
testcase_12 AC 239 ms
117,924 KB
testcase_13 AC 245 ms
120,060 KB
testcase_14 AC 71 ms
71,228 KB
testcase_15 AC 243 ms
119,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
a = list(map(int, input().split()))
for i in range(N):
    a[i] = a[i] % 10
dp = [[0] * 10 for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    for j in range(10):
        if dp[i][j] != 0:
            dp[i + 1][(j + a[i]) % 10] = max(dp[i + 1][(j + a[i]) % 10], dp[i][j] + 1)
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])

print(dp[N][0] - 1)
0