import java.util.*;
class jobschedule {
static int n, d, m;
static int [] requests;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
d = sc.nextInt();
m = sc.nextInt();
requests = new int[m];
for(int i = 0; i < m; i++){
requests[i]=sc.nextInt();
}
Arrays.sort(requests);
//System.out.println(Arrays.toString(requests));
int left = 1;
int right = m;
while(left!=right){
int mid = left + (right-left)/2;
if(works(mid)){
right=mid;
}else{
left=mid+1;
}
}
System.out.println(left);
for(int i = 0; i < n; i++){
System.out.println(0);
}
}
public static boolean works(int machines){
int [] timeArray = new int[m];
int time = 1;
timeArray[0]=1;
int currentMachines = machines-1;
for(int i = 1; i < m; i++){
if(requests[i]==requests[i-1]){
if(currentMachines==0){
currentMachines=machines-1;
time++;
timeArray[i]=time;
}else{
currentMachines--;
timeArray[i]=time;
}
}else{
time=Math.max(time+1, requests[i]);
timeArray[i]=time;
currentMachines=machines-1;
}
}
for(int i = 0; i < m; i++){
if(timeArray[i]-requests[i]>d){
return false;
}
}
return true;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
143 ms |
12072 KB |
Execution failed because the return code was nonzero |
2 |
Runtime error |
141 ms |
11948 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
150 ms |
12396 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
143 ms |
11924 KB |
Execution failed because the return code was nonzero |
5 |
Runtime error |
133 ms |
12160 KB |
Execution failed because the return code was nonzero |
6 |
Runtime error |
140 ms |
12428 KB |
Execution failed because the return code was nonzero |
7 |
Runtime error |
144 ms |
12284 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
132 ms |
12232 KB |
Execution failed because the return code was nonzero |
9 |
Runtime error |
154 ms |
12252 KB |
Execution failed because the return code was nonzero |
10 |
Runtime error |
137 ms |
12252 KB |
Execution failed because the return code was nonzero |
11 |
Runtime error |
153 ms |
11976 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
155 ms |
12228 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
137 ms |
12032 KB |
Execution failed because the return code was nonzero |
14 |
Runtime error |
130 ms |
12052 KB |
Execution failed because the return code was nonzero |
15 |
Runtime error |
147 ms |
11920 KB |
Execution failed because the return code was nonzero |
16 |
Runtime error |
145 ms |
12136 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
139 ms |
12096 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
132 ms |
12032 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
143 ms |
12044 KB |
Execution failed because the return code was nonzero |
20 |
Runtime error |
142 ms |
12248 KB |
Execution failed because the return code was nonzero |