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 = min(n,50000)
while lo < hi:
mid = (lo+hi)//2
if check(mid):
hi = mid
else:
lo = mid+1
print(lo)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
80 ms |
30696 KB |
Output isn't correct |
2 |
Incorrect |
80 ms |
30524 KB |
Output isn't correct |
3 |
Incorrect |
79 ms |
30676 KB |
Output isn't correct |
4 |
Incorrect |
83 ms |
30492 KB |
Output isn't correct |
5 |
Incorrect |
85 ms |
30496 KB |
Output isn't correct |
6 |
Incorrect |
80 ms |
30688 KB |
Output isn't correct |
7 |
Incorrect |
82 ms |
30484 KB |
Output isn't correct |
8 |
Incorrect |
81 ms |
30488 KB |
Output isn't correct |
9 |
Runtime error |
99 ms |
33600 KB |
Memory limit exceeded |
10 |
Runtime error |
111 ms |
33608 KB |
Memory limit exceeded |
11 |
Incorrect |
107 ms |
30760 KB |
Unexpected end of file - int32 expected |
12 |
Runtime error |
149 ms |
35364 KB |
Memory limit exceeded |
13 |
Runtime error |
187 ms |
43404 KB |
Memory limit exceeded |
14 |
Runtime error |
246 ms |
57048 KB |
Memory limit exceeded |
15 |
Runtime error |
253 ms |
59196 KB |
Memory limit exceeded |
16 |
Runtime error |
342 ms |
65536 KB |
Memory limit exceeded |
17 |
Runtime error |
147 ms |
65536 KB |
Execution killed with signal 9 |
18 |
Runtime error |
145 ms |
65540 KB |
Execution killed with signal 9 |
19 |
Runtime error |
145 ms |
65540 KB |
Execution killed with signal 9 |
20 |
Runtime error |
159 ms |
65536 KB |
Execution killed with signal 9 |