# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
724575 |
2023-04-15T14:48:51 Z |
vjudge1 |
Stove (JOI18_stove) |
Java 11 |
|
774 ms |
22936 KB |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
class stove {
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);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
10444 KB |
Output is correct |
2 |
Correct |
96 ms |
10056 KB |
Output is correct |
3 |
Correct |
97 ms |
10212 KB |
Output is correct |
4 |
Correct |
104 ms |
10048 KB |
Output is correct |
5 |
Correct |
100 ms |
10444 KB |
Output is correct |
6 |
Correct |
97 ms |
10460 KB |
Output is correct |
7 |
Correct |
100 ms |
10292 KB |
Output is correct |
8 |
Correct |
101 ms |
10264 KB |
Output is correct |
9 |
Correct |
97 ms |
10020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
10444 KB |
Output is correct |
2 |
Correct |
96 ms |
10056 KB |
Output is correct |
3 |
Correct |
97 ms |
10212 KB |
Output is correct |
4 |
Correct |
104 ms |
10048 KB |
Output is correct |
5 |
Correct |
100 ms |
10444 KB |
Output is correct |
6 |
Correct |
97 ms |
10460 KB |
Output is correct |
7 |
Correct |
100 ms |
10292 KB |
Output is correct |
8 |
Correct |
101 ms |
10264 KB |
Output is correct |
9 |
Correct |
97 ms |
10020 KB |
Output is correct |
10 |
Correct |
312 ms |
15012 KB |
Output is correct |
11 |
Correct |
311 ms |
15276 KB |
Output is correct |
12 |
Correct |
320 ms |
14944 KB |
Output is correct |
13 |
Correct |
320 ms |
15144 KB |
Output is correct |
14 |
Correct |
351 ms |
15468 KB |
Output is correct |
15 |
Correct |
308 ms |
15296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
10444 KB |
Output is correct |
2 |
Correct |
96 ms |
10056 KB |
Output is correct |
3 |
Correct |
97 ms |
10212 KB |
Output is correct |
4 |
Correct |
104 ms |
10048 KB |
Output is correct |
5 |
Correct |
100 ms |
10444 KB |
Output is correct |
6 |
Correct |
97 ms |
10460 KB |
Output is correct |
7 |
Correct |
100 ms |
10292 KB |
Output is correct |
8 |
Correct |
101 ms |
10264 KB |
Output is correct |
9 |
Correct |
97 ms |
10020 KB |
Output is correct |
10 |
Correct |
312 ms |
15012 KB |
Output is correct |
11 |
Correct |
311 ms |
15276 KB |
Output is correct |
12 |
Correct |
320 ms |
14944 KB |
Output is correct |
13 |
Correct |
320 ms |
15144 KB |
Output is correct |
14 |
Correct |
351 ms |
15468 KB |
Output is correct |
15 |
Correct |
308 ms |
15296 KB |
Output is correct |
16 |
Correct |
699 ms |
22532 KB |
Output is correct |
17 |
Correct |
774 ms |
22936 KB |
Output is correct |
18 |
Correct |
735 ms |
22696 KB |
Output is correct |
19 |
Correct |
754 ms |
22784 KB |
Output is correct |
20 |
Correct |
731 ms |
22776 KB |
Output is correct |
21 |
Correct |
756 ms |
22624 KB |
Output is correct |
22 |
Correct |
761 ms |
22832 KB |
Output is correct |
23 |
Correct |
699 ms |
22812 KB |
Output is correct |
24 |
Correct |
770 ms |
22760 KB |
Output is correct |