If there are positively fresh fruits, only the positively fresh fruits are adopted in order from the largest (all if there are no K). Even if there are only 0 or less fruits, b, the most 0 Adopt only one close one.
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
print(A[0] + sum([a for a in A[1:] if a > 0][:K - 1]))
I don't know, so I wrote a code that just turns the loop a lot and checks if it becomes 0, and then AC (terrible). Since A and B are large, I do TLE after 10 5 </ sup> turns. ..
A, B = map(int, input().split())
N = 0
for i in range(1, 10000):
N = A * N + B
if N == 0:
print(i)
exit()
print(-1)
After K operations, N becomes L * K <= N <= R * K. There is an operation sequence such that N = 0 if the multiple of the maximum M less than or equal to R * K is A or more. This means. ABC165A --We Love Golf when A is L * K and B is R * K with * O * (1) It's a problem to solve (laughs).
L, R, M, K = map(int, input().split())
if R * K // M * M >= L * K:
print('Yes')
else:
print('No')
Recommended Posts