import java.io.*;
import java.util.*;
class jobs {
static int n, d, m;
static int[] jobs;
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new FileReader("jobs.in"));
PrintWriter pw = new PrintWriter("jobs.out");
StringTokenizer st = new StringTokenizer(r.readLine());
n = Integer.parseInt(st.nextToken());
d = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
jobs = new int[n + d];
ArrayList<Integer>[] ids = new ArrayList[n];
for (int i=0; i<n; i++){
ids[i] = new ArrayList<Integer>();
}
st = new StringTokenizer(r.readLine());
for (int i=0; i<m; i++){
int day = Integer.parseInt(st.nextToken())-1;
jobs[day]++;
ids[day].add(i+1);
}
for (int i=1; i<n + d; i++){
jobs[i] += jobs[i-1];
}
int lo = 1;
int hi = m;
while (lo < hi){
int mid = (lo + hi) / 2;
if (ok(mid)) hi = mid;
else lo = mid + 1;
}
pw.println(lo);
int total = 0;
for (int i=0; i<n; i++){
int count = 0;
int ind = 0;
while (count < lo && total < m){
for (int j=0; j<ids[ind].size(); j++){
if (count == lo) break;
pw.print(ids[ind].get(j) + " ");
count++;
ids[ind].remove(j);
j--;
}
ind++;
}
pw.println(0);
total += count;
}
pw.close();
}
static boolean ok (int lim){
int count = 0;
int[] t = jobs.clone();
for (int i=0; i<n + d; i++){
int curr = Math.min(lim, Math.max(t[i], 0));
count += curr;
if (i < n + d - 1){
t[i+1] -= curr;
}
}
return count >= m;
}
}
Compilation message
Note: jobs.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
57 ms |
8352 KB |
Execution failed because the return code was nonzero |
2 |
Runtime error |
56 ms |
8124 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
56 ms |
8196 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
63 ms |
8172 KB |
Execution failed because the return code was nonzero |
5 |
Runtime error |
63 ms |
8220 KB |
Execution failed because the return code was nonzero |
6 |
Runtime error |
76 ms |
8328 KB |
Execution failed because the return code was nonzero |
7 |
Runtime error |
66 ms |
8328 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
55 ms |
8108 KB |
Execution failed because the return code was nonzero |
9 |
Runtime error |
56 ms |
8100 KB |
Execution failed because the return code was nonzero |
10 |
Runtime error |
57 ms |
8052 KB |
Execution failed because the return code was nonzero |
11 |
Runtime error |
61 ms |
8132 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
69 ms |
8196 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
71 ms |
8304 KB |
Execution failed because the return code was nonzero |
14 |
Runtime error |
56 ms |
8232 KB |
Execution failed because the return code was nonzero |
15 |
Runtime error |
59 ms |
8604 KB |
Execution failed because the return code was nonzero |
16 |
Runtime error |
60 ms |
8156 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
60 ms |
8312 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
71 ms |
8200 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
63 ms |
8024 KB |
Execution failed because the return code was nonzero |
20 |
Runtime error |
63 ms |
8320 KB |
Execution failed because the return code was nonzero |