結果

問題 No.1231 Make a Multiple of Ten
ユーザー ryo_nryo_n
提出日時 2020-09-19 02:30:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 394 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 133,676 KB
最終ジャッジ日時 2023-09-05 18:25:53
合計ジャッジ時間 4,737 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,516 KB
testcase_01 AC 93 ms
71,580 KB
testcase_02 AC 95 ms
71,616 KB
testcase_03 AC 95 ms
71,692 KB
testcase_04 AC 245 ms
104,492 KB
testcase_05 AC 226 ms
99,048 KB
testcase_06 AC 155 ms
84,776 KB
testcase_07 AC 248 ms
105,284 KB
testcase_08 AC 190 ms
93,712 KB
testcase_09 AC 143 ms
82,224 KB
testcase_10 AC 234 ms
99,416 KB
testcase_11 AC 263 ms
105,948 KB
testcase_12 AC 382 ms
132,460 KB
testcase_13 AC 394 ms
133,664 KB
testcase_14 AC 95 ms
71,340 KB
testcase_15 AC 392 ms
133,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    dp = [[-float("inf")] * 10 for j in range(N + 1)]

    dp[0][0] = 0
    for i in range(N):
        a = A[i - 1]
        for j in range(10):
            if dp[i][j] == -float("inf"):
                continue
            dp[i + 1][(j + a) % 10] = max(dp[i + 1][(j + a) % 10], dp[i][j] + 1)
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

    print(dp[N][0])





    
    

if __name__ == '__main__':
    main()

0