結果

問題 No.1231 Make a Multiple of Ten
ユーザー mkawa2mkawa2
提出日時 2021-08-14 16:44:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 935 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 24,512 KB
最終ジャッジ日時 2024-04-15 14:45:05
合計ジャッジ時間 7,413 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7


n = II()
aa = LI()
cnt = [0]*10
r = 0
for a in aa:
    a %= 10
    cnt[a] += 1
    r += a
    r %= 10

def dfs(i=1, c=0, s=0):
    if s == r: return c
    if i == 10: return inf
    res = inf
    for j in range(min(10, cnt[i]+1)):
        res = min(res, dfs(i+1, c+j, (s+j*i)%10))
    return res

mn = dfs()
print(n-mn)
0