#include <bits/stdc++.h>
using namespace std;
int zle[100003];
int wej[1000003];
vector<int> ans[100003];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,d,m;
cin >> n >> d >> m;
for (int i = 1; i<=m; i++){
cin >> wej[i];
zle[wej[i]]++;
ans[wej[i]].push_back(i);
}
sort(wej+1,wej+m+1);
int l=1,p=m,md;
while(l<p){
md=(l+p)/2;
bool ok=true;
int ind=1;
for (int i = 1; i<=n; i++){
for (int j = 1; j<=md; j++){
if (ind>m || wej[j]>i)break;
ind++;
}
if (ind<=m && (wej[ind]+d)<=i){
ok=false;
break;
}
}
if (ok)p=md;
else l=md+1;
}
cout << l << '\n';
// for (int i = 1; i<=n; i++){
// for (auto u : ans[i])q.push(u);
// for (int j = 1; j<=l; j++){
// if (q.empty())break;
// cout << q.front() << ' ';
// q.pop();
// }
// cout << "0\n";
// }
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
3804 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
8 ms |
3804 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
7 ms |
3808 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
8 ms |
3808 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
7 ms |
3808 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
7 ms |
3984 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
7 ms |
3808 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
8 ms |
3808 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
10 ms |
4124 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
10 ms |
3932 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
11 ms |
4048 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
21 ms |
5212 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
32 ms |
7248 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
54 ms |
8788 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
52 ms |
9712 KB |
Output isn't correct |
16 |
Incorrect |
88 ms |
11856 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
94 ms |
13904 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
81 ms |
13336 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
103 ms |
14160 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
99 ms |
13908 KB |
Unexpected end of file - int32 expected |