結果

問題 No.1231 Make a Multiple of Ten
ユーザー Mottchan
提出日時 2025-09-03 17:33:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 1,315 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 82,668 KB
実行使用メモリ 139,636 KB
最終ジャッジ日時 2025-09-03 17:33:27
合計ジャッジ時間 4,721 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
# 0~9を並び替えるならpermutationsかconbinations,N列のカテゴリを作るにはproduct
from itertools import product, permutations, combinations, accumulate
from functools import lru_cache  # @lru_cache(maxsize=128)
import operator
from string import ascii_uppercase, ascii_lowercase, digits  # 英字(大文字), 英字(小文字), 数字
MOD = 998244353
def II(): return int(input())
def LI(): return list(input())
def LMI(): return list(map(int, input().split()))
def LMS(): return list(map(str, input().split()))
def LLMI(x): return [list(map(int, input().split())) for _ in range(x)]
def LLMS(x): return [list(input()) for _ in range(x)]
  
def execute():
    n = II()
    a = LMI()

    dp = [[-float('inf')] * 10 for _ in range(n+1)]
    dp[0][0] = 0
    # 余りだけ考えればよいね

    for i in range(1, n+1):
        for j in range(10):
            dp[i][j] =  max(dp[i][j], dp[i-1][(j-a[i-1]) % 10] + 1)
            dp[i][j] = max(dp[i][j], dp[i-1][j])
    # print(dp)

    result = 0
    for i in range(n+1):
        result = max(result, dp[i][0])
    
    print(result)

if __name__ == "__main__":
    T = 1
    for _ in range(T):
        execute()
0