# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119583 | johu | Job Scheduling (CEOI12_jobs) | Java | 63 ms | 9240 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.util.*;
import java.io.*;
public class jobs {
static BufferedReader br = new BufferedReader(new InputStreamReader(new DataInputStream(System.in)));
static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
static StringTokenizer st;
public static void main(String[] args) throws IOException {
int N = nextInt(), D = nextInt(), M = nextInt(), cnt[] = new int[N + 1];
for (int i = 0; i < M; i++)
cnt[nextInt()]++;
int l = 1, r = M, ans = 0;
while (l <= r) {
int m = (l + r) >> 1;
boolean b = true;
Deque<Integer> dq = new ArrayDeque<>();
for (int i = 1; i <= N; i++) {
if (!dq.isEmpty() && dq.peekFirst() < i) {
b = false;
break;
}
for (int j = 0; j < cnt[i]; j++)
dq.addLast(i + D);
for (int j = 0; j < m; j++) {
if (dq.isEmpty()) break;
dq.pollFirst();
}
}
if (b) {
r = m - 1;
ans = m;
}
else
l = m + 1;
}
System.out.println(ans);
for (int i = 0; i < N; i++)
System.out.println(0);
}
static int nextInt() throws IOException {
return Integer.parseInt(st.nextToken());
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |