Submission #1139191

#TimeUsernameProblemLanguageResultExecution timeMemory
1139191tobilliskJob Scheduling (CEOI12_jobs)C++20
Compilation error
0 ms0 KiB
import java.util.*;
import java.io.*;

public class Submit {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        
        StringTokenizer st = new StringTokenizer(f.readLine());
        int N = Integer.parseInt(st.nextToken());
        int D = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        job[] jobs = new job[M];

        st = new StringTokenizer(f.readLine());
        for (int m = 0; m < M; m++) jobs[m] = new job(m, Integer.parseInt(st.nextToken()));

        Arrays.sort (jobs, (a, b) -> a.t-b.t);

        int[] js = new int[N];

        for (job j: jobs) js[j.t]++;

        int gapsize = D * 2 - 1;
        int sum = 0;
        int distance = 0;
        int comps = 0;

        for (int n = 0; n < N; n++) {
            if (distance < gapsize) distance++;
            else sum -= js[n-gapsize];

            if (distance > D) comps = Math.max(comps, (sum + distance - 1) / distance);

            sum += js[n];
        }

        out.println(comps);

        int start = 0;
        int i = 0;

        for (int n = 0; n < N; n++) {
            for (int j = 0; j < comps; j++) {
                if (start > n) break;
                if (i == M) break;
                out.print(jobs[i].i + 1 + " ");
                i++;
                js[start]--;
                if (js[start] == 0) start++;
            } out.println("0");
        }

        out.close(); f.close();
    }
}

class job {int i; int t; job (int i, int t) {this.i = i; this.t = t;}}

Compilation message (stderr)

jobs.cpp:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
jobs.cpp:1:1: note: C++20 'import' only available with '-fmodules-ts', which is not yet enabled with '-std=c++20'
jobs.cpp:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
jobs.cpp:2:1: note: C++20 'import' only available with '-fmodules-ts', which is not yet enabled with '-std=c++20'
jobs.cpp:4:1: error: expected unqualified-id before 'public'
    4 | public class Submit {
      | ^~~~~~
jobs.cpp:59:71: error: expected ';' after class definition
   59 | class job {int i; int t; job (int i, int t) {this.i = i; this.t = t;}}
      |                                                                       ^
      |                                                                       ;
jobs.cpp: In constructor 'job::job(int, int)':
jobs.cpp:59:51: error: request for member 'i' in '(job*)this', which is of pointer type 'job*' (maybe you meant to use '->' ?)
   59 | class job {int i; int t; job (int i, int t) {this.i = i; this.t = t;}}
      |                                                   ^
jobs.cpp:59:63: error: request for member 't' in '(job*)this', which is of pointer type 'job*' (maybe you meant to use '->' ?)
   59 | class job {int i; int t; job (int i, int t) {this.i = i; this.t = t;}}
      |                                                               ^