n,d,m = map(int,input().split())
nums = [int(x) for x in input().split()]
nums.sort()
def check(x):
thing = [0]*m
count = 1
curr = 0
right = 0
while right < m:
while right < min(m,curr+x):
if nums[right]<=count:
thing[right]=count
right+=1
else:
curr = right
count+=1
count+=1
curr+=x
final = 0
for i in range(m):
if thing[i]-nums[i]>final:
final = thing[i]-nums[i]
return final <= d
lo = 1
hi = n
while lo < hi:
mid = (lo+hi)//2
if check(mid):
hi = mid
else:
lo = mid+1
print(lo)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
95 ms |
30692 KB |
Output isn't correct |
2 |
Incorrect |
86 ms |
30480 KB |
Output isn't correct |
3 |
Incorrect |
84 ms |
30508 KB |
Output isn't correct |
4 |
Incorrect |
88 ms |
30724 KB |
Output isn't correct |
5 |
Incorrect |
79 ms |
30500 KB |
Output isn't correct |
6 |
Incorrect |
79 ms |
30480 KB |
Output isn't correct |
7 |
Incorrect |
79 ms |
30468 KB |
Output isn't correct |
8 |
Incorrect |
81 ms |
30468 KB |
Output isn't correct |
9 |
Runtime error |
118 ms |
33592 KB |
Memory limit exceeded |
10 |
Runtime error |
116 ms |
33636 KB |
Memory limit exceeded |
11 |
Incorrect |
103 ms |
30660 KB |
Unexpected end of file - int32 expected |
12 |
Runtime error |
141 ms |
35392 KB |
Memory limit exceeded |
13 |
Runtime error |
177 ms |
43344 KB |
Memory limit exceeded |
14 |
Runtime error |
265 ms |
57064 KB |
Memory limit exceeded |
15 |
Runtime error |
252 ms |
59276 KB |
Memory limit exceeded |
16 |
Runtime error |
350 ms |
65536 KB |
Memory limit exceeded |
17 |
Runtime error |
145 ms |
65536 KB |
Execution killed with signal 9 |
18 |
Runtime error |
161 ms |
65536 KB |
Execution killed with signal 9 |
19 |
Runtime error |
146 ms |
65540 KB |
Execution killed with signal 9 |
20 |
Runtime error |
153 ms |
65536 KB |
Execution killed with signal 9 |