11555 | 2024-10-26 19:03:36 | balint | Pontos átlag 2 | python3 | Accepted 100/100 | 1.879s | 26228 KiB |
def main():
N, K = map(int, input().strip().split())
nums = list(map(int, input().strip().split()))
target_sum = K * N
def can_achieve_with_C(C):
lower_sum, upper_sum = 0, 0
for num in nums:
lower_sum += max(num - C, 1)
upper_sum += num + C
return lower_sum <= target_sum <= upper_sum
left, right = 0, max(abs(K - min(nums)), abs(K - max(nums)))
while left < right:
mid = (left + right) // 2
if can_achieve_with_C(mid):
right = mid
else:
left = mid + 1
print(left)
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 16ms | 3316 KiB | ||||
2 | Accepted | 16ms | 3128 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 14ms | 3060 KiB | ||||
4 | Accepted | 16ms | 3128 KiB | ||||
5 | Accepted | 16ms | 3076 KiB | ||||
6 | Accepted | 16ms | 3124 KiB | ||||
7 | Accepted | 16ms | 3128 KiB | ||||
8 | Accepted | 16ms | 2972 KiB | ||||
subtask3 | 20/20 | ||||||
9 | Accepted | 152ms | 6812 KiB | ||||
10 | Accepted | 153ms | 7088 KiB | ||||
11 | Accepted | 194ms | 6468 KiB | ||||
12 | Accepted | 199ms | 6456 KiB | ||||
13 | Accepted | 204ms | 6780 KiB | ||||
14 | Accepted | 153ms | 7064 KiB | ||||
15 | Accepted | 204ms | 7032 KiB | ||||
16 | Accepted | 203ms | 7220 KiB | ||||
17 | Accepted | 16ms | 3128 KiB | ||||
subtask4 | 24/24 | ||||||
18 | Accepted | 26ms | 3120 KiB | ||||
19 | Accepted | 26ms | 3124 KiB | ||||
20 | Accepted | 25ms | 3320 KiB | ||||
21 | Accepted | 19ms | 3132 KiB | ||||
22 | Accepted | 20ms | 3248 KiB | ||||
23 | Accepted | 23ms | 3016 KiB | ||||
24 | Accepted | 24ms | 3012 KiB | ||||
25 | Accepted | 25ms | 3052 KiB | ||||
26 | Accepted | 24ms | 3128 KiB | ||||
27 | Accepted | 19ms | 3116 KiB | ||||
28 | Accepted | 17ms | 3128 KiB | ||||
subtask5 | 46/46 | ||||||
29 | Accepted | 203ms | 7112 KiB | ||||
30 | Accepted | 804ms | 26228 KiB | ||||
31 | Accepted | 790ms | 15856 KiB | ||||
32 | Accepted | 1.179s | 21184 KiB | ||||
33 | Accepted | 1.345s | 25000 KiB | ||||
34 | Accepted | 1.578s | 24980 KiB | ||||
35 | Accepted | 1.745s | 24844 KiB | ||||
36 | Accepted | 1.781s | 24908 KiB | ||||
37 | Accepted | 1.879s | 24836 KiB | ||||
38 | Accepted | 1.83s | 24620 KiB | ||||
39 | Accepted | 677ms | 10644 KiB | ||||
40 | Accepted | 41ms | 3640 KiB | ||||
41 | Accepted | 17ms | 3128 KiB |