結果

問題 No.1231 Make a Multiple of Ten
コンテスト
ユーザー ryo_n
提出日時 2020-09-19 02:27:38
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 773 ms / 2,000 ms
+ 810µs
コード長 523 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 265 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 108,508 KB
最終ジャッジ日時 2026-10-12 16:58:04
合計ジャッジ時間 6,354 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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