Submission #1119560

#TimeUsernameProblemLanguageResultExecution timeMemory
1119560johuJob Scheduling (CEOI12_jobs)Java
Compilation error
0 ms0 KiB
import java.io.*; import java.util.*; public class Main { private static final int MX = (int) 1e6 + 5; private static int N, M, D; private static int[] cnt = new int[MX]; private static boolean f(int x) { Deque<Integer> dq = new ArrayDeque<>(); for (int i = 1; i <= N; i++) { if (!dq.isEmpty() && dq.peekFirst() < i) return false; for (int j = 0; j < cnt[i]; j++) dq.addLast(i + D); for (int j = 0; j < x; j++) { if (dq.isEmpty()) break; dq.pollFirst(); } } return dq.isEmpty(); } public static void main(String[] args) throws IOException { DataInputStream dis = new DataInputStream(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(dis)); StringTokenizer st = new StringTokenizer(br.readLine()); N = Integer.parseInt(st.nextToken()); D = Integer.parseInt(st.nextToken()); M = Integer.parseInt(st.nextToken()); Arrays.fill(cnt, 0); for (int i = 0; i < M; i++) { int x = Integer.parseInt(br.readLine()); cnt[x]++; } int l = 1, r = M, ans = 0; while (l <= r) { int mid = (l + r) >> 1; if (f(mid)) { r = mid - 1; ans = mid; } else { l = mid + 1; } } System.out.println(ans); for (int i = 0; i < N; i++) System.out.println(0); } }

Compilation message (stderr)

jobs.java:4: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error