結果

問題 No.1231 Make a Multiple of Ten
ユーザー ryo_nryo_n
提出日時 2020-09-19 02:28:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 295 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 129,096 KB
最終ジャッジ日時 2023-09-05 18:25:48
合計ジャッジ時間 4,217 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,780 KB
testcase_01 AC 96 ms
71,372 KB
testcase_02 AC 97 ms
71,760 KB
testcase_03 AC 95 ms
71,820 KB
testcase_04 AC 189 ms
97,916 KB
testcase_05 AC 188 ms
97,056 KB
testcase_06 AC 145 ms
84,628 KB
testcase_07 AC 209 ms
106,036 KB
testcase_08 AC 158 ms
92,000 KB
testcase_09 AC 121 ms
78,708 KB
testcase_10 AC 189 ms
97,584 KB
testcase_11 AC 213 ms
106,948 KB
testcase_12 AC 285 ms
128,828 KB
testcase_13 AC 294 ms
129,096 KB
testcase_14 AC 94 ms
71,848 KB
testcase_15 AC 295 ms
129,044 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(1, N + 1):
        a = A[i - 1]
        for j in range(10):
            dp[i][(j + a) % 10] = max(dp[i][(j + a) % 10], dp[i - 1][j] + 1)
            dp[i][j] = max(dp[i][j], dp[i - 1][j])

    print(dp[N][0])





    
    

if __name__ == '__main__':
    main()

0