#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, d, m;
vector<pii> arr;
bool check(int machines){
int job = m-1;
for(int day = n; day >= 1; day--){
int cnt = 0;
while(arr[job].first - day <= d && cnt + 1 <= machines){
job--;
cnt++;
}
if(job < 0) return true;
}
return false;
}
int main(){
cin>>n>>d>>m;
arr.resize(m);
for(int i = 0; i < m; i++)
{
cin>>arr[i].first;
arr[i].second = i;
}
sort(arr.begin(), arr.end());
int l = 1, r = n, ans = -1;
while(l <= r){
int mid = (l + r) / 2;
bool can = check(mid);
if(can){
ans = mid;
r = mid - 1;
}
else
l = mid + 1;
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
1104 KB |
Output isn't correct |
2 |
Incorrect |
20 ms |
980 KB |
Output isn't correct |
3 |
Incorrect |
20 ms |
980 KB |
Output isn't correct |
4 |
Incorrect |
21 ms |
980 KB |
Output isn't correct |
5 |
Incorrect |
24 ms |
980 KB |
Output isn't correct |
6 |
Incorrect |
25 ms |
992 KB |
Output isn't correct |
7 |
Incorrect |
20 ms |
1088 KB |
Output isn't correct |
8 |
Incorrect |
21 ms |
1096 KB |
Output isn't correct |
9 |
Incorrect |
27 ms |
980 KB |
Output isn't correct |
10 |
Incorrect |
26 ms |
980 KB |
Output isn't correct |
11 |
Incorrect |
33 ms |
1068 KB |
Output isn't correct |
12 |
Incorrect |
63 ms |
1748 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
89 ms |
2644 KB |
Output isn't correct |
14 |
Incorrect |
142 ms |
3424 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
153 ms |
4204 KB |
Output isn't correct |
16 |
Incorrect |
212 ms |
4948 KB |
Output isn't correct |
17 |
Incorrect |
239 ms |
5772 KB |
Output isn't correct |
18 |
Incorrect |
254 ms |
6560 KB |
Output isn't correct |
19 |
Incorrect |
286 ms |
7332 KB |
Output isn't correct |
20 |
Incorrect |
226 ms |
5772 KB |
Output isn't correct |