Submission #1119473

#TimeUsernameProblemLanguageResultExecution timeMemory
1119473johuJob Scheduling (CEOI12_jobs)Java
0 / 100
1105 ms55432 KiB
import java.util.Arrays; import java.util.Scanner; public class jobs { static final int mxn = 1000005; static Pair[] a = new Pair[mxn]; static class Pair { int fr, sc; Pair(int fr, int sc) { this.fr = fr; this.sc = sc; } } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int d = scanner.nextInt(); int m = scanner.nextInt(); for (int i = 1; i <= m; i++) { a[i] = new Pair(scanner.nextInt(), i); } a[m + 1] = new Pair(1000000000, 0); Arrays.sort(a, 1, m + 1, (p1, p2) -> Integer.compare(p1.fr, p2.fr)); int l = 0, r = m; while (r - l > 1) { int mid = (l + r) / 2; int 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); } scanner.close(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...