結果

問題 No.1231 Make a Multiple of Ten
ユーザー ryo_nryo_n
提出日時 2020-09-19 02:04:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 655 ms / 2,000 ms
コード長 1,251 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 99,768 KB
最終ジャッジ日時 2023-09-05 18:25:44
合計ジャッジ時間 7,501 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 192 ms
77,696 KB
testcase_01 AC 98 ms
71,728 KB
testcase_02 AC 98 ms
71,724 KB
testcase_03 AC 100 ms
71,604 KB
testcase_04 AC 497 ms
86,816 KB
testcase_05 AC 648 ms
85,704 KB
testcase_06 AC 481 ms
80,316 KB
testcase_07 AC 655 ms
87,796 KB
testcase_08 AC 485 ms
83,520 KB
testcase_09 AC 491 ms
79,516 KB
testcase_10 AC 510 ms
86,628 KB
testcase_11 AC 498 ms
88,036 KB
testcase_12 AC 161 ms
98,960 KB
testcase_13 AC 528 ms
99,292 KB
testcase_14 AC 98 ms
71,580 KB
testcase_15 AC 527 ms
99,768 KB
権限があれば一括ダウンロードができます

ソースコード

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