Submission #1119583

#TimeUsernameProblemLanguageResultExecution timeMemory
1119583johuJob Scheduling (CEOI12_jobs)Java
0 / 100
63 ms9240 KiB
import java.util.*; import java.io.*; public class jobs { static BufferedReader br = new BufferedReader(new InputStreamReader(new DataInputStream(System.in))); static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static StringTokenizer st; public static void main(String[] args) throws IOException { int N = nextInt(), D = nextInt(), M = nextInt(), cnt[] = new int[N + 1]; for (int i = 0; i < M; i++) cnt[nextInt()]++; int l = 1, r = M, ans = 0; while (l <= r) { int m = (l + r) >> 1; boolean b = true; Deque<Integer> dq = new ArrayDeque<>(); for (int i = 1; i <= N; i++) { if (!dq.isEmpty() && dq.peekFirst() < i) { b = false; break; } for (int j = 0; j < cnt[i]; j++) dq.addLast(i + D); for (int j = 0; j < m; j++) { if (dq.isEmpty()) break; dq.pollFirst(); } } if (b) { r = m - 1; ans = m; } else l = m + 1; } System.out.println(ans); for (int i = 0; i < N; i++) System.out.println(0); } static int nextInt() throws IOException { return Integer.parseInt(st.nextToken()); } }
#Verdict Execution timeMemoryGrader output
Fetching results...