# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
724568 |
2023-04-15T14:35:14 Z |
browntoad |
Stove (JOI18_stove) |
Java 11 |
|
792 ms |
23596 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 |
96 ms |
10492 KB |
Output is correct |
2 |
Correct |
95 ms |
10212 KB |
Output is correct |
3 |
Correct |
91 ms |
10236 KB |
Output is correct |
4 |
Correct |
103 ms |
10220 KB |
Output is correct |
5 |
Correct |
100 ms |
10368 KB |
Output is correct |
6 |
Correct |
98 ms |
10252 KB |
Output is correct |
7 |
Correct |
100 ms |
10228 KB |
Output is correct |
8 |
Correct |
98 ms |
10272 KB |
Output is correct |
9 |
Correct |
97 ms |
10364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
10492 KB |
Output is correct |
2 |
Correct |
95 ms |
10212 KB |
Output is correct |
3 |
Correct |
91 ms |
10236 KB |
Output is correct |
4 |
Correct |
103 ms |
10220 KB |
Output is correct |
5 |
Correct |
100 ms |
10368 KB |
Output is correct |
6 |
Correct |
98 ms |
10252 KB |
Output is correct |
7 |
Correct |
100 ms |
10228 KB |
Output is correct |
8 |
Correct |
98 ms |
10272 KB |
Output is correct |
9 |
Correct |
97 ms |
10364 KB |
Output is correct |
10 |
Correct |
306 ms |
15196 KB |
Output is correct |
11 |
Correct |
312 ms |
15060 KB |
Output is correct |
12 |
Correct |
298 ms |
14896 KB |
Output is correct |
13 |
Correct |
307 ms |
15240 KB |
Output is correct |
14 |
Correct |
339 ms |
15400 KB |
Output is correct |
15 |
Correct |
303 ms |
14976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
10492 KB |
Output is correct |
2 |
Correct |
95 ms |
10212 KB |
Output is correct |
3 |
Correct |
91 ms |
10236 KB |
Output is correct |
4 |
Correct |
103 ms |
10220 KB |
Output is correct |
5 |
Correct |
100 ms |
10368 KB |
Output is correct |
6 |
Correct |
98 ms |
10252 KB |
Output is correct |
7 |
Correct |
100 ms |
10228 KB |
Output is correct |
8 |
Correct |
98 ms |
10272 KB |
Output is correct |
9 |
Correct |
97 ms |
10364 KB |
Output is correct |
10 |
Correct |
306 ms |
15196 KB |
Output is correct |
11 |
Correct |
312 ms |
15060 KB |
Output is correct |
12 |
Correct |
298 ms |
14896 KB |
Output is correct |
13 |
Correct |
307 ms |
15240 KB |
Output is correct |
14 |
Correct |
339 ms |
15400 KB |
Output is correct |
15 |
Correct |
303 ms |
14976 KB |
Output is correct |
16 |
Correct |
706 ms |
23368 KB |
Output is correct |
17 |
Correct |
766 ms |
23588 KB |
Output is correct |
18 |
Correct |
709 ms |
23360 KB |
Output is correct |
19 |
Correct |
723 ms |
23128 KB |
Output is correct |
20 |
Correct |
792 ms |
23472 KB |
Output is correct |
21 |
Correct |
688 ms |
23376 KB |
Output is correct |
22 |
Correct |
685 ms |
23596 KB |
Output is correct |
23 |
Correct |
702 ms |
23344 KB |
Output is correct |
24 |
Correct |
764 ms |
23540 KB |
Output is correct |