# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119472 | johu | Job Scheduling (CEOI12_jobs) | Java | 308 ms | 65536 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class jobs {
static class Pair {
int fr, sc;
Pair(int fr, int sc) {
this.fr = fr;
this.sc = sc;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] firstLine = br.readLine().split(" ");
int n = Integer.parseInt(firstLine[0]);
int d = Integer.parseInt(firstLine[1]);
int m = Integer.parseInt(firstLine[2]);
Pair[] a = new Pair[m + 2];
for (int i = 1; i <= m; i++) {
int value = Integer.parseInt(br.readLine().split(" ")[i - 1]);
a[i] = new Pair(value, i);
}
a[m + 1] = new Pair(Integer.MAX_VALUE, 0);
Arrays.sort(a, 1, m + 1, (x, y) -> Integer.compare(x.fr, y.fr));
int l = 0, r = m;
while (r - l > 1) {
int mid = (l + r) / 2, p = 1;
for (int i = 1; i <= n; i++) {
if (a[p].fr + d < i) {
break;
}
int cnt = 0;
while (cnt < mid && a[p].fr <= i) {
cnt++;
p++;
}
}
if (p > m) {
r = mid;
} else {
l = mid;
}
}
System.out.println(r);
int p = 1;
for (int i = 1; i <= n; i++) {
int cnt = 0;
while (cnt < r && a[p].fr <= i) {
cnt++;
System.out.print(a[p].sc + " ");
p++;
}
System.out.println(0);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |