import java.io.*;
import java.util.*;
class Main {
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 |
141 ms |
12144 KB |
Execution failed because the return code was nonzero |
2 |
Runtime error |
138 ms |
11996 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
135 ms |
12180 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
144 ms |
11936 KB |
Execution failed because the return code was nonzero |
5 |
Runtime error |
132 ms |
11940 KB |
Execution failed because the return code was nonzero |
6 |
Runtime error |
139 ms |
11932 KB |
Execution failed because the return code was nonzero |
7 |
Runtime error |
134 ms |
12016 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
137 ms |
12088 KB |
Execution failed because the return code was nonzero |
9 |
Runtime error |
133 ms |
12060 KB |
Execution failed because the return code was nonzero |
10 |
Runtime error |
135 ms |
12032 KB |
Execution failed because the return code was nonzero |
11 |
Runtime error |
150 ms |
12208 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
137 ms |
11968 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
137 ms |
12172 KB |
Execution failed because the return code was nonzero |
14 |
Runtime error |
132 ms |
12408 KB |
Execution failed because the return code was nonzero |
15 |
Runtime error |
136 ms |
11972 KB |
Execution failed because the return code was nonzero |
16 |
Runtime error |
147 ms |
11988 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
135 ms |
12140 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
133 ms |
12288 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
130 ms |
11964 KB |
Execution failed because the return code was nonzero |
20 |
Runtime error |
151 ms |
12144 KB |
Execution failed because the return code was nonzero |