結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
ryo_n
|
| 提出日時 | 2020-09-19 02:04:15 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,251 bytes |
| コンパイル時間 | 403 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 27,684 KB |
| 最終ジャッジ日時 | 2024-06-22 17:14:33 |
| 合計ジャッジ時間 | 5,821 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 11 |
ソースコード
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()
ryo_n