#include<bits/stdc++.h>
using namespace std;
int n, d, m, day[1000100];
vector<int> times[100100];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> d >> m;
for(int i = 1; i <= m; ++i){
cin >> day[i];
times[day[i]].push_back(i);
}
int l = 1, r = 1e9;
while(l < r){
int mid = (l + r) >> 1, check = true;
queue<int> q;
for(int i = 1; i<=n; ++i){
int k = mid;
for(auto x:times[i]) q.push(x);
while(k-- && !q.empty()) q.pop();
if(!q.empty() && day[q.front()] + d == i){
check = false;
break;
}
}
if(check) r = mid;
else l = mid+1;
}
cout << l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
5852 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
11 ms |
5852 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
11 ms |
5852 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
15 ms |
5852 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
12 ms |
5852 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
12 ms |
5852 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
12 ms |
5836 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
12 ms |
5852 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
16 ms |
5464 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
17 ms |
5468 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
13 ms |
5464 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
22 ms |
6488 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
39 ms |
8028 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
57 ms |
9388 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
51 ms |
9552 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
81 ms |
12052 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
109 ms |
14028 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
81 ms |
13484 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
97 ms |
14176 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
106 ms |
14044 KB |
Unexpected end of file - int32 expected |