Submission #724531

# Submission time Handle Problem Language Result Execution time Memory
724531 2023-04-15T13:46:53 Z vjudge1 Stove (JOI18_stove) Java 11
Compilation error
0 ms 0 KB
class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        ArrayList<Integer> times = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int arrival = scanner.nextInt();
            times.add(arrival);
        }
        int length = times.get(N-1) + 1 - times.get(0);

        ArrayList<Integer> diffTimes = new ArrayList<>();
        for (int i=1; i < times.size(); i++) {
            diffTimes.add(times.get(i) - times.get(i-1) - 1);
        }

        Collections.sort(diffTimes);

        int sum = 0;
        for (int i = N-K; i < N-1; i++) {
            sum += diffTimes.get(i);
        }
        System.out.println(length - sum);
    }
}

Compilation message

stove.java:3: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
stove.java:3: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
stove.java:7: error: cannot find symbol
        ArrayList<Integer> times = new ArrayList<>();
        ^
  symbol:   class ArrayList
  location: class Main
stove.java:7: error: cannot find symbol
        ArrayList<Integer> times = new ArrayList<>();
                                       ^
  symbol:   class ArrayList
  location: class Main
stove.java:15: error: cannot find symbol
        ArrayList<Integer> diffTimes = new ArrayList<>();
        ^
  symbol:   class ArrayList
  location: class Main
stove.java:15: error: cannot find symbol
        ArrayList<Integer> diffTimes = new ArrayList<>();
                                           ^
  symbol:   class ArrayList
  location: class Main
stove.java:20: error: cannot find symbol
        Collections.sort(diffTimes);
        ^
  symbol:   variable Collections
  location: class Main
7 errors