結果

問題 No.1231 Make a Multiple of Ten
ユーザー tcltktcltk
提出日時 2021-01-16 07:43:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 123,940 KB
最終ジャッジ日時 2024-05-05 10:31:43
合計ジャッジ時間 5,551 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
88,984 KB
testcase_01 AC 134 ms
88,588 KB
testcase_02 AC 134 ms
88,564 KB
testcase_03 AC 133 ms
89,112 KB
testcase_04 AC 220 ms
105,708 KB
testcase_05 AC 205 ms
103,792 KB
testcase_06 AC 168 ms
95,540 KB
testcase_07 AC 219 ms
106,972 KB
testcase_08 AC 184 ms
98,720 KB
testcase_09 AC 160 ms
92,956 KB
testcase_10 AC 210 ms
105,036 KB
testcase_11 AC 219 ms
106,648 KB
testcase_12 AC 303 ms
123,472 KB
testcase_13 AC 310 ms
123,940 KB
testcase_14 AC 133 ms
88,980 KB
testcase_15 AC 302 ms
123,628 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