제출 #1183011

#제출 시각아이디문제언어결과실행 시간메모리
1183011fyanJob Scheduling (CEOI12_jobs)Java
0 / 100
351 ms131072 KiB
import java.io.*; import java.util.*; public class jobs { static final int MX = (int)1e6 + 6; static final int nax = (int)1e5 + 5; static Pair[] in = new Pair[MX]; static ArrayList<Integer>[] C = new ArrayList[nax]; static ArrayList<Integer>[] ans = new ArrayList[nax]; static class Pair implements Comparable<Pair> { int first, second; Pair(int first, int second) { this.first = first; this.second = second; } public int compareTo(Pair o) { return Integer.compare(this.first, o.first); } } static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static int readInt() throws IOException { int v = 0; int c = br.read(); while (c < '0' || c > '9') c = br.read(); while ('0' <= c && c <= '9') { v = v * 10 + (c - '0'); c = br.read(); } return v; } static void writeInt(int x, boolean newline) throws IOException { if (x == 0) bw.write('0'); else bw.write(Integer.toString(x)); if (newline) bw.write("\n"); else bw.write(" "); } static boolean check(int x, boolean CREATE, int N, int D) { int cur = 0, len = 0; for (int i = 0; i < N; i++) { if (cur < len && in[cur].first <= i) return false; int end = i + D + 1; for (int c : C[i]) { in[len++] = new Pair(end, c); } if (CREATE) { int left = x; while (left-- > 0 && cur < len) { ans[i].add(in[cur++].second); } } else cur = Math.min(len, cur + x); } return cur == len; } public static void main(String[] args) throws IOException { int N = readInt(), D = readInt(), M = readInt(); for (int i = 0; i < nax; i++) { C[i] = new ArrayList<>(); ans[i] = new ArrayList<>(); } for (int i = 0; i < M; i++) { int t = readInt() - 1; C[t].add(i); } int lo = 1, hi = M; while (lo < hi) { int mid = (lo + hi) / 2; if (check(mid, false, N, D)) hi = mid; else lo = mid + 1; } check(lo, true, N, D); writeInt(lo, true); for (int i = 0; i < N; i++) { for (int x : ans[i]) writeInt(x + 1, false); writeInt(0, true); } bw.flush(); } }

컴파일 시 표준 에러 (stderr) 메시지

Note: jobs.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

=======
#Verdict Execution timeMemoryGrader output
Fetching results...