Official
B - 募金活動の最小チーム数 / Minimum Number of Teams for Fundraising Editorial
by
B - 募金活動の最小チーム数 / Minimum Number of Teams for Fundraising Editorial
by
sounansya
まず、選ぶチームは募金額が大きい順に選べば良いです。
あとは総和が基準額を超えるまでチームを選び続け、その選んだチーム数を出力すれば良いです。
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a)
now = 0
for i in range(n):
now += a[i]
if 2 * now >= s:
print(i + 1)
break
posted:
last update:
