ABC 318 C - Blue Spring
https://atcoder.jp/contests/abc318/tasks/abc318_c
提出
code: python
n, d, p = map(int, input().split())
f = list(map(int, input().split()))
f.sort(reverse=True)
ans = 0
while len(f) >= d:
tmp = 0
for _ in range(d):
tmp += f.pop(0)
if tmp > p:
ans += p
else:
ans += tmp
break
print(ans, f)
解答
code: python
n, d, p = map(int, input().split())
f = list(map(int, input().split()))
f.sort(reverse=True)
for left in range(0, n, d):
right = min(left + d, n)
cost = sum(fleft:right)
if cost > p:
for i in range(left, right):
fi = 0
fleft = p
else:
break
# print(f)
# 10, 0, 6, 3, 1
# 1000000000, 0, 0, 1000000000, 0, 0, 1000000000, 0
ans = sum(f)
print(ans)
メモ
https://qiita.com/hyouchun/items/0c8fad4a7aa1d7bad60c