import java.util.*;
import java.io.*;
public class Main {
static pair[] inp;
static int N, D, M;
// TLE && RTE
public static void main(String[] args) throws IOException, FileNotFoundException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//BufferedReader in = new BufferedReader(new FileReader("test.in"));
StringTokenizer st = new StringTokenizer(in.readLine());
M = Integer.parseInt(st.nextToken());
D = Integer.parseInt(st.nextToken());
N = Integer.parseInt(st.nextToken());
inp = new pair[N];
st = new StringTokenizer(in.readLine());
for (int i=0; i<N; ++i) {
inp[i] = new pair(Integer.parseInt(st.nextToken()), i+1);
}
Arrays.sort(inp);
int a=1, b=N;
while (a != b) {
int mid = (a+b)/2;
if (works(mid)) b = mid;
else a = mid+1;
}
System.out.println(a);
int at = 0;
for (int j=0; j<M; j++) {
int cnt = 0;
while (at != N && inp[at].val <= j && cnt <a) {
cnt++;
System.out.print(inp[at].index + " ");
at++;
}
System.out.println(0);
}
}
public static boolean works(int m) {
int day = 1;
int lef = m;
for (int i=0; i<N; i++) {
if (inp[i].val > day) {day=inp[i].val; lef = m;}
if (inp[i].val + D < day) return false;
lef--;
if (lef == 0) {day++; lef=m;}
}
return true;
}
public static class pair implements Comparable<pair> {
public int val, index;
public pair(int a, int b) {
this.val = a;
this.index = b;
}
@Override
public int compareTo(pair other) {
return val - other.val;
}
}
}
Compilation message
jobs.java:4: error: class Main is public, should be declared in a file named Main.java
public class Main {
^
1 error