結果

問題 No.1231 Make a Multiple of Ten
ユーザー tcltktcltk
提出日時 2021-01-16 07:43:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 406 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 130,680 KB
最終ジャッジ日時 2023-08-18 04:04:05
合計ジャッジ時間 7,738 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 238 ms
83,296 KB
testcase_01 AC 233 ms
83,508 KB
testcase_02 AC 238 ms
83,300 KB
testcase_03 AC 231 ms
83,380 KB
testcase_04 AC 345 ms
107,628 KB
testcase_05 AC 314 ms
103,760 KB
testcase_06 AC 276 ms
91,596 KB
testcase_07 AC 327 ms
107,996 KB
testcase_08 AC 288 ms
95,936 KB
testcase_09 AC 260 ms
87,760 KB
testcase_10 AC 320 ms
106,376 KB
testcase_11 AC 335 ms
109,652 KB
testcase_12 AC 394 ms
128,328 KB
testcase_13 AC 401 ms
130,408 KB
testcase_14 AC 234 ms
83,396 KB
testcase_15 AC 406 ms
130,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)



def main():
    N = int(input())
    A = list(map(int, input().split()))

    dp = [[-10**10 for _ in range(10)] for _ in range(N+1)]

    # dp[i][k] := i枚以下のカードで,総和の余りがkになる取り方の枚数の総和
    dp[0][0] = 0

    for i in range(1, N+1):
        a = A[i-1] % 10
        for k in range(10):
            dp[i][k] = max(dp[i-1][k], dp[i-1][k-a] + 1)

    print(dp[N][0])

if __name__ == '__main__':
    main()
0