-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2512.py
49 lines (40 loc) · 898 Bytes
/
2512.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import sys
N = int(sys.stdin.readline())
r_answer = list(map(int, input().split()))
M = int(sys.stdin.readline())
start = 0
end = max(r_answer)
while start <= end:
mid = (start+end)//2
total = 0
for i in r_answer:
total += min(mid , i)
if total <= M :
start = mid + 1
else :
end = mid - 1
print(end)
# import sys
#
# N = int(sys.stdin.readline())
# r_answer = list(map(int, input().split()))
# M = int(sys.stdin.readline())
# answer = 0
#
# while (M >= N and N !=0):
# k = M // N
# answer += k
# for i in range(len(r_answer)):
# if r_answer[i] >= k:
# M -= k
# r_answer[i] -= k
# elif r_answer[i] < k and r_answer[i] > 0 :
# M -= r_answer[i]
# r_answer[i] = 0
# t = 0
# for i in r_answer:
# if i != 0 :
# t += 1
# N = t
#
# print(answer)