Submission #1119468

#TimeUsernameProblemLanguageResultExecution timeMemory
1119468johuJob Scheduling (CEOI12_jobs)Java
0 / 100
343 ms65536 KiB
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class jobs { static class Pair { int fr, sc; Pair(int fr, int sc) { this.fr = fr; this.sc = sc; } } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] firstLine = br.readLine().split(" "); int n = Integer.parseInt(firstLine[0]); int d = Integer.parseInt(firstLine[1]); int m = Integer.parseInt(firstLine[2]); Pair[] a = new Pair[m + 2]; for (int i = 1; i <= m; i++) { int value = Integer.parseInt(br.readLine().split(" ")[i - 1]); a[i] = new Pair(value, i); } a[m + 1] = new Pair(1000000000, 0); Arrays.sort(a, 1, m + 1, (x, y) -> Integer.compare(x.fr, y.fr)); int l = 0, r = m; while (r - l > 1) { int mid = (l + r) / 2, p = 1; for (int i = 1; i <= n; i++) { if (a[p].fr + d < i) { break; } int cnt = 0; while (cnt < mid && a[p].fr <= i) { cnt++; p++; } } if (p > m) { r = mid; } else { l = mid; } } System.out.println(r); int p = 1; for (int i = 1; i <= n; i++) { int cnt = 0; while (cnt < r && a[p].fr <= i) { cnt++; System.out.print(a[p].sc + " "); p++; } System.out.println(0); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...