結果

問題 No.1231 Make a Multiple of Ten
ユーザー ryo_nryo_n
提出日時 2020-09-19 02:27:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,575 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 107,460 KB
最終ジャッジ日時 2023-09-04 20:38:46
合計ジャッジ時間 11,467 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,664 KB
testcase_01 AC 17 ms
8,608 KB
testcase_02 AC 17 ms
8,592 KB
testcase_03 AC 18 ms
8,556 KB
testcase_04 AC 728 ms
52,820 KB
testcase_05 AC 623 ms
47,380 KB
testcase_06 AC 255 ms
23,628 KB
testcase_07 AC 760 ms
54,792 KB
testcase_08 AC 432 ms
34,988 KB
testcase_09 AC 162 ms
17,200 KB
testcase_10 AC 667 ms
49,392 KB
testcase_11 AC 808 ms
58,312 KB
testcase_12 AC 1,500 ms
101,828 KB
testcase_13 AC 1,572 ms
105,900 KB
testcase_14 AC 19 ms
8,528 KB
testcase_15 AC 1,575 ms
107,460 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