import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class jobSheduling {
// 7 mins planning
static int N,D,M;
static Integer [] requests;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
StringTokenizer s = new StringTokenizer(br.readLine());
N = Integer.parseInt(s.nextToken());
D = Integer.parseInt(s.nextToken());
M = Integer.parseInt(s.nextToken());
requests = new Integer [M];
s = new StringTokenizer(br.readLine());
for (int i = 0; i < M; i++) {
requests[i] = Integer.parseInt(s.nextToken());
}
Arrays.sort(requests);
int a = 1, b = M;
while (a != b) {
int mid = (a+b)/2;
if (works(mid)) b=mid;
else a = mid+1;
}
out.println(b);
out.close();
}
static boolean works (int numMachines) {
int [] lastDays = new int [numMachines];
int maxD = 0;
for (int i = 0, currMach = 0; i < M; i++,currMach++) {
int currDay = requests[i];
if (currMach == numMachines) currMach = 0;
int nextMachDay = lastDays[currMach]+1;
if (nextMachDay > currDay) {
maxD = Math.max(maxD,nextMachDay-currDay);
lastDays[currMach] = nextMachDay;
}
else {
lastDays[currMach] = currDay;
}
}
return maxD <= D;
}
}
Compilation message
jobs.java:9: error: class jobSheduling is public, should be declared in a file named jobSheduling.java
public class jobSheduling {
^
1 error