結果
問題 |
No.1231 Make a Multiple of Ten
|
ユーザー |
![]() |
提出日時 | 2020-09-19 02:04:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 586 ms / 2,000 ms |
コード長 | 1,251 bytes |
コンパイル時間 | 156 ms |
コンパイル使用メモリ | 82,156 KB |
実行使用メモリ | 98,280 KB |
最終ジャッジ日時 | 2024-06-23 13:54:20 |
合計ジャッジ時間 | 6,255 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
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()