import java.util.*;
import java.io.*;
public class jobs {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
static StringTokenizer st;
public static void main(String[] args) throws IOException {
int N = nextInt(), D = nextInt(), M = nextInt();
HashSet<Integer>[] s = new HashSet[N + 1];
for (int i = 1; i <= N; i++)
s[i] = new HashSet<>();
for (int i = 1; i <= M; i++)
s[nextInt()].add(i);
int L = 0, R = 10000, m = 0;
while (L < R) {
m = (L + R) / 2;
boolean b = true;
int dd = 1, r = 0;
for (int i = 1; i <= N; i++) {
if (s[i].size() == 0)
continue;
if (dd < i - D) {
dd = i - D;
r = 0;
}
dd += (s[i].size() + r) / m;
r = (s[i].size() + r) % m;
if (dd > i + 1 || dd == i + 1 && r > 0) {
b = false;
break;
}
}
if (b)
R = m;
else
L = m + 1;
}
System.out.println(m);
ArrayDeque<Integer> a = new ArrayDeque<>();
for (int i = 1; i <= N; i++) {
for (int j : s[i])
a.addLast(j);
int cnt = 0;
while (cnt++ < m && !a.isEmpty())
System.out.print(a.pollFirst() + " ");
System.out.println(0);
}
}
static String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine().trim());
return st.nextToken();
}
static char nextChar() throws IOException {
return next().charAt(0);
}
static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static long nextLong() throws IOException {
return Long.parseLong(next());
}
static String nextLine() throws IOException {
return br.readLine().trim();
}
}
Compilation message
Note: jobs.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
837 ms |
31188 KB |
Output isn't correct |
2 |
Incorrect |
835 ms |
31132 KB |
Output isn't correct |
3 |
Incorrect |
830 ms |
31212 KB |
Output isn't correct |
4 |
Incorrect |
893 ms |
31128 KB |
Output isn't correct |
5 |
Incorrect |
870 ms |
31176 KB |
Output isn't correct |
6 |
Incorrect |
928 ms |
31140 KB |
Output isn't correct |
7 |
Incorrect |
920 ms |
31732 KB |
Output isn't correct |
8 |
Incorrect |
914 ms |
31180 KB |
Output isn't correct |
9 |
Execution timed out |
1064 ms |
42556 KB |
Time limit exceeded |
10 |
Execution timed out |
1082 ms |
40100 KB |
Time limit exceeded |
11 |
Incorrect |
871 ms |
26716 KB |
Output isn't correct |
12 |
Execution timed out |
1052 ms |
40112 KB |
Time limit exceeded |
13 |
Execution timed out |
1056 ms |
49008 KB |
Time limit exceeded |
14 |
Execution timed out |
1049 ms |
54336 KB |
Time limit exceeded |
15 |
Execution timed out |
1063 ms |
60392 KB |
Time limit exceeded |
16 |
Runtime error |
551 ms |
65536 KB |
Execution killed with signal 9 |
17 |
Runtime error |
511 ms |
65536 KB |
Execution killed with signal 9 |
18 |
Runtime error |
573 ms |
65536 KB |
Execution killed with signal 9 |
19 |
Runtime error |
466 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
584 ms |
65536 KB |
Execution killed with signal 9 |