# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119466 | johu | Job Scheduling (CEOI12_jobs) | Java | 335 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 final int mxn = 1000005;
static int n, m, d;
static Pair[] a = new Pair[mxn];
static class Pair implements Comparable<Pair> {
int fr, sc;
Pair(int fr, int sc) {
this.fr = fr;
this.sc = sc;
}
@Override
public int compareTo(Pair other) {
return Integer.compare(this.fr, other.fr);
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().split(" ");
n = Integer.parseInt(input[0]);
d = Integer.parseInt(input[1]);
m = Integer.parseInt(input[2]);
for (int i = 1; i <= m; i++) {
input = br.readLine().split(" ");
a[i] = new Pair(Integer.parseInt(input[0]), i);
}
a[m + 1] = new Pair(1000000000, 0);
Arrays.sort(a, 1, m + 1);
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... |