# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119561 | johu | Job Scheduling (CEOI12_jobs) | Java | 226 ms | 42924 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.io.*;
import java.util.*;
public class jobs {
private static final int MX = (int) 1e6 + 5;
private static int N, M, D;
private static int[] cnt = new int[MX];
private static boolean f(int x) {
Deque<Integer> dq = new ArrayDeque<>();
for (int i = 1; i <= N; i++) {
if (!dq.isEmpty() && dq.peekFirst() < i) return false;
for (int j = 0; j < cnt[i]; j++) dq.addLast(i + D);
for (int j = 0; j < x; j++) {
if (dq.isEmpty()) break;
dq.pollFirst();
}
}
return dq.isEmpty();
}
public static void main(String[] args) throws IOException {
DataInputStream dis = new DataInputStream(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
D = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());
Arrays.fill(cnt, 0);
for (int i = 0; i < M; i++) {
int x = Integer.parseInt(br.readLine());
cnt[x]++;
}
int l = 1, r = M, ans = 0;
while (l <= r) {
int mid = (l + r) >> 1;
if (f(mid)) {
r = mid - 1;
ans = mid;
} else {
l = mid + 1;
}
}
System.out.println(ans);
for (int i = 0; i < N; i++) System.out.println(0);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |