Submission #377322

# Submission time Handle Problem Language Result Execution time Memory
377322 2021-03-13T23:23:48 Z timg8710 Stove (JOI18_stove) Java 11
100 / 100
490 ms 18112 KB
// package olypmiads;

import java.io.*;
import java.util.*;
@SuppressWarnings("unchecked")
public class stove {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken())-1;
        List<Integer> gaps = new ArrayList();
        int c = Integer.parseInt(br.readLine());
        int ret = 1;
        for(int i = 0; i<N-1; i++){
            int n = Integer.parseInt(br.readLine());
            gaps.add(n - c - 1);
            ret += n - c;
            c = n;
        }
        
        Collections.sort(gaps, Collections.reverseOrder());
        for(int i = 0; i<Math.min(K, gaps.size()); i++) ret -= gaps.get(i);
        pw.println(ret);
        pw.close();
        br.close();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 75 ms 8536 KB Output is correct
2 Correct 73 ms 8676 KB Output is correct
3 Correct 73 ms 8556 KB Output is correct
4 Correct 75 ms 8576 KB Output is correct
5 Correct 77 ms 8444 KB Output is correct
6 Correct 72 ms 8556 KB Output is correct
7 Correct 75 ms 8576 KB Output is correct
8 Correct 74 ms 8556 KB Output is correct
9 Correct 74 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 8536 KB Output is correct
2 Correct 73 ms 8676 KB Output is correct
3 Correct 73 ms 8556 KB Output is correct
4 Correct 75 ms 8576 KB Output is correct
5 Correct 77 ms 8444 KB Output is correct
6 Correct 72 ms 8556 KB Output is correct
7 Correct 75 ms 8576 KB Output is correct
8 Correct 74 ms 8556 KB Output is correct
9 Correct 74 ms 8556 KB Output is correct
10 Correct 243 ms 12228 KB Output is correct
11 Correct 219 ms 12488 KB Output is correct
12 Correct 235 ms 12512 KB Output is correct
13 Correct 226 ms 12688 KB Output is correct
14 Correct 280 ms 12696 KB Output is correct
15 Correct 193 ms 12128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 8536 KB Output is correct
2 Correct 73 ms 8676 KB Output is correct
3 Correct 73 ms 8556 KB Output is correct
4 Correct 75 ms 8576 KB Output is correct
5 Correct 77 ms 8444 KB Output is correct
6 Correct 72 ms 8556 KB Output is correct
7 Correct 75 ms 8576 KB Output is correct
8 Correct 74 ms 8556 KB Output is correct
9 Correct 74 ms 8556 KB Output is correct
10 Correct 243 ms 12228 KB Output is correct
11 Correct 219 ms 12488 KB Output is correct
12 Correct 235 ms 12512 KB Output is correct
13 Correct 226 ms 12688 KB Output is correct
14 Correct 280 ms 12696 KB Output is correct
15 Correct 193 ms 12128 KB Output is correct
16 Correct 413 ms 17816 KB Output is correct
17 Correct 404 ms 17944 KB Output is correct
18 Correct 370 ms 18092 KB Output is correct
19 Correct 379 ms 17996 KB Output is correct
20 Correct 490 ms 18020 KB Output is correct
21 Correct 418 ms 18112 KB Output is correct
22 Correct 414 ms 17752 KB Output is correct
23 Correct 376 ms 18072 KB Output is correct
24 Correct 418 ms 17956 KB Output is correct