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 |
1 |
Runtime error |
192 ms |
24360 KB |
Execution failed because the return code was nonzero |
2 |
Runtime error |
169 ms |
25044 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
194 ms |
24632 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
176 ms |
24784 KB |
Execution failed because the return code was nonzero |
5 |
Runtime error |
200 ms |
24988 KB |
Execution failed because the return code was nonzero |
6 |
Runtime error |
198 ms |
24972 KB |
Execution failed because the return code was nonzero |
7 |
Runtime error |
205 ms |
24680 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
181 ms |
24620 KB |
Execution failed because the return code was nonzero |
9 |
Runtime error |
165 ms |
21352 KB |
Execution failed because the return code was nonzero |
10 |
Runtime error |
191 ms |
21968 KB |
Execution failed because the return code was nonzero |
11 |
Runtime error |
202 ms |
25028 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
226 ms |
27888 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
248 ms |
36660 KB |
Execution failed because the return code was nonzero |
14 |
Runtime error |
257 ms |
51120 KB |
Execution failed because the return code was nonzero |
15 |
Runtime error |
271 ms |
50616 KB |
Execution failed because the return code was nonzero |
16 |
Runtime error |
292 ms |
65536 KB |
Execution killed with signal 9 |
17 |
Runtime error |
335 ms |
65536 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
330 ms |
65536 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
303 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
326 ms |
65532 KB |
Execution failed because the return code was nonzero |