#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int N, D, M;
int jobs[10000001];
bool test(int x){
int tracker = 0;
for (int n = 1; n <= N; n++){
int itter = tracker;
for (int c = itter; c < itter+x; c++){
if (tracker < M){
if (jobs[tracker] <= n){
if (jobs[tracker]+D < n){
return false;
}
tracker++;
}
else {
break;
}
}
else {
return true;
}
}
}
return true;
}
int main(int argc, const char * argv[]) {
//ifstream cin ("file.in"); ofstream cout ("file.out");
cin >> N >> D >> M;
for (int m = 0; m < M; m++){
cin >> jobs[m];
}
sort(jobs, jobs + M);
int low = 1;
int high = 1000000000;
while (low < high){
int middle = (low + high)/2;
// cout << "High: " << high << " Low: " << low << " Middle: " << middle << endl;
if (test(middle)){
if (middle == 1){
// cout << "ONE";
}
high = middle;
}
else {
low = middle + 1;
}
}
cout << low;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
748 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
24 ms |
748 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
24 ms |
748 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
24 ms |
876 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
24 ms |
748 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
24 ms |
748 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
24 ms |
748 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
23 ms |
748 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
25 ms |
748 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
25 ms |
748 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
33 ms |
748 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
63 ms |
1260 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
93 ms |
1516 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
145 ms |
1900 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
161 ms |
2336 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
222 ms |
2732 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
250 ms |
3180 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
243 ms |
3436 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
298 ms |
3948 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
253 ms |
3108 KB |
Unexpected end of file - int32 expected |