結果

問題 No.1231 Make a Multiple of Ten
ユーザー ryo_nryo_n
提出日時 2020-09-19 02:04:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,251 bytes
コンパイル時間 1,108 ms
コンパイル使用メモリ 10,680 KB
実行使用メモリ 22,968 KB
最終ジャッジ日時 2023-09-04 19:34:05
合計ジャッジ時間 5,580 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 757 ms
13,040 KB
testcase_01 AC 19 ms
8,692 KB
testcase_02 AC 18 ms
8,520 KB
testcase_03 AC 18 ms
8,476 KB
testcase_04 TLE -
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
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [x % 10 for x in A]

    B.sort()

    c = collections.Counter(B)

    total = sum(B) % 10

    if total == 0:
        print(N)
    else:
        ans = float("inf")
        for one in range(min(c[1] + 1, 10)):
            for two in range(min(c[2] + 1, 5)):
                for three in range(min(c[3] + 1, 10)):
                    for four in range(min(c[4] + 1, 5)):
                        for five in range(min(c[5] + 1, 2)):
                            for six in range(min(c[6] + 1, 5)):
                                for seven in range(min(c[7] + 1, 10)):
                                    for eight in range(min(c[8] + 1, 5)):
                                        for nine in range(min(c[9] + 1, 10)):
                                            if (one + two * 2 + three * 3 + four * 4 + five * 5 + six * 6 + seven * 7 + eight * 8 + nine * 9) % 10 == total:
                                                ans = min(ans, one + two + three + four + five + six + seven + eight + nine)

        print(N - ans)


    
    

if __name__ == '__main__':
    main()

0