답안 #1119472

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1119472 2024-11-27T05:06:43 Z johu Job Scheduling (CEOI12_jobs) Java 11
0 / 100
308 ms 65536 KB
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(Integer.MAX_VALUE, 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);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 181 ms 20072 KB Execution failed because the return code was nonzero
2 Runtime error 162 ms 21064 KB Execution failed because the return code was nonzero
3 Runtime error 180 ms 20648 KB Execution failed because the return code was nonzero
4 Runtime error 163 ms 20952 KB Execution failed because the return code was nonzero
5 Runtime error 178 ms 21144 KB Execution failed because the return code was nonzero
6 Runtime error 169 ms 20848 KB Execution failed because the return code was nonzero
7 Runtime error 164 ms 20608 KB Execution failed because the return code was nonzero
8 Runtime error 161 ms 20920 KB Execution failed because the return code was nonzero
9 Runtime error 168 ms 18120 KB Execution failed because the return code was nonzero
10 Runtime error 183 ms 18148 KB Execution failed because the return code was nonzero
11 Runtime error 166 ms 20504 KB Execution failed because the return code was nonzero
12 Runtime error 191 ms 26840 KB Execution failed because the return code was nonzero
13 Runtime error 230 ms 36476 KB Execution failed because the return code was nonzero
14 Runtime error 229 ms 41192 KB Execution failed because the return code was nonzero
15 Runtime error 227 ms 48308 KB Execution failed because the return code was nonzero
16 Runtime error 307 ms 65536 KB Execution failed because the return code was nonzero
17 Runtime error 255 ms 64240 KB Execution failed because the return code was nonzero
18 Runtime error 263 ms 65536 KB Execution killed with signal 9
19 Runtime error 308 ms 65536 KB Execution killed with signal 9
20 Runtime error 261 ms 62156 KB Execution failed because the return code was nonzero