import java.util.*;
class jobs {
public static Pair [] arr;
public static int m;
public static int d;
public static int n;
public static int [] times;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
n = s.nextInt();
d = s.nextInt();
m = s.nextInt();
arr = new Pair [m];
System.out.println(n);
System.exit(0);
for (int i = 0; i < m; i++) {
arr[i] = new Pair (s.nextInt(), i + 1);
}
Arrays.sort(arr);
int a = 1, b = m;
int mid = 1;
while (a != b) {
mid = (a + b) / 2;
if (simulate(mid)) {
b = mid;
}
else {
a = mid + 1;
}
}
if (!simulate(mid)) {
simulate(mid + 1);
mid++;
System.out.println(mid);
}
else {
simulate(mid);
System.out.println(mid);
}
int pos = 0;
int dayf = 1;
boolean done = false;
for (int i = 0; i < n; i++) {
//System.out.println(pos + mid + "h" + done);
if (done) {
System.out.println(0);
continue;
}
if ((pos + mid) >= m) {
done = true;
}
for (int j = pos; j < m; j++) {
//System.out.println(j + " " + dayf + " " + times[j]);
if (!(dayf == times[j])) {
dayf++;
pos = j;
break;
}
System.out.print(arr[j].index + " ");
}
System.out.print(0);
System.out.println();
}
}
public static boolean simulate (int x) {
int counter = 1;
int day = 1;
times = new int [m];
for (int i = 0; i < m; i++) {
times[i] = day;
counter++;
if (counter > x) {
counter = 1;
day++;
}
}
//System.out.println(Arrays.toString(times) + " " + x);
for (int i = 0; i < m; i++) {
if (times[i] - arr[i].sorter > d) {
return false;
}
}
return true;
}
private static class Pair implements Comparable<Pair> {
int sorter;
int index;
public Pair(int location, int index) {
this.sorter = location;
this.index = index;
}
@Override
public int compareTo(Pair o) {
return sorter - o.sorter;
}
@Override
public boolean equals (Object other) {
Pair nother = (Pair) other;
return nother.sorter == sorter;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
125 ms |
10292 KB |
Output isn't correct |
2 |
Incorrect |
129 ms |
10436 KB |
Output isn't correct |
3 |
Incorrect |
126 ms |
10436 KB |
Output isn't correct |
4 |
Incorrect |
137 ms |
10120 KB |
Output isn't correct |
5 |
Incorrect |
130 ms |
10516 KB |
Output isn't correct |
6 |
Incorrect |
126 ms |
10532 KB |
Output isn't correct |
7 |
Incorrect |
146 ms |
10348 KB |
Output isn't correct |
8 |
Incorrect |
128 ms |
10432 KB |
Output isn't correct |
9 |
Incorrect |
128 ms |
10556 KB |
Output isn't correct |
10 |
Incorrect |
121 ms |
10344 KB |
Output isn't correct |
11 |
Incorrect |
129 ms |
10160 KB |
Output isn't correct |
12 |
Incorrect |
126 ms |
10644 KB |
Output isn't correct |
13 |
Incorrect |
128 ms |
10972 KB |
Output isn't correct |
14 |
Incorrect |
130 ms |
11180 KB |
Output isn't correct |
15 |
Incorrect |
136 ms |
11692 KB |
Output isn't correct |
16 |
Incorrect |
122 ms |
12616 KB |
Output isn't correct |
17 |
Incorrect |
124 ms |
12972 KB |
Output isn't correct |
18 |
Incorrect |
121 ms |
13528 KB |
Output isn't correct |
19 |
Incorrect |
129 ms |
13652 KB |
Output isn't correct |
20 |
Incorrect |
124 ms |
12976 KB |
Output isn't correct |