# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
716745 |
2023-03-31T01:27:34 Z |
browntoad |
Stove (JOI18_stove) |
Java 11 |
|
1000 ms |
19084 KB |
import java.io.*;
import java.util.*;
public class stove
{
public static void main(String[] args) {
Scanner obj = new Scanner(System.in);
int n, k;
n = obj.nextInt();
k = obj.nextInt();
int arr[] = new int [n];
for (int i=0; i<n; i++){
arr[i] = obj.nextInt();
}
int ans = n;
if (n == 1){
System.out.println(ans);
return;
}
int sarr[] = new int[n-1];
for (int i=0; i<n-1; i++){
sarr[i] = arr[i+1]-arr[i]-1;
}
for (int i=0; i<n-2; i++){
int id = i;
for (int j=i+1; j<n-1; j++){
if (sarr[j]<sarr[id]){
id=j;
}
}
int tmp = sarr[id];
sarr[id] = sarr[i];
sarr[i] = tmp;
}
for(int i=0; i<n-k; i++){
ans += sarr[i];
}
System.out.println(ans);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
10880 KB |
Output is correct |
2 |
Correct |
96 ms |
10120 KB |
Output is correct |
3 |
Correct |
97 ms |
10260 KB |
Output is correct |
4 |
Correct |
99 ms |
10292 KB |
Output is correct |
5 |
Correct |
103 ms |
10028 KB |
Output is correct |
6 |
Correct |
98 ms |
10204 KB |
Output is correct |
7 |
Correct |
99 ms |
10380 KB |
Output is correct |
8 |
Correct |
96 ms |
10304 KB |
Output is correct |
9 |
Correct |
94 ms |
10240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
10880 KB |
Output is correct |
2 |
Correct |
96 ms |
10120 KB |
Output is correct |
3 |
Correct |
97 ms |
10260 KB |
Output is correct |
4 |
Correct |
99 ms |
10292 KB |
Output is correct |
5 |
Correct |
103 ms |
10028 KB |
Output is correct |
6 |
Correct |
98 ms |
10204 KB |
Output is correct |
7 |
Correct |
99 ms |
10380 KB |
Output is correct |
8 |
Correct |
96 ms |
10304 KB |
Output is correct |
9 |
Correct |
94 ms |
10240 KB |
Output is correct |
10 |
Correct |
309 ms |
15096 KB |
Output is correct |
11 |
Correct |
298 ms |
14972 KB |
Output is correct |
12 |
Correct |
299 ms |
15008 KB |
Output is correct |
13 |
Correct |
303 ms |
14936 KB |
Output is correct |
14 |
Correct |
315 ms |
14944 KB |
Output is correct |
15 |
Correct |
315 ms |
15016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
10880 KB |
Output is correct |
2 |
Correct |
96 ms |
10120 KB |
Output is correct |
3 |
Correct |
97 ms |
10260 KB |
Output is correct |
4 |
Correct |
99 ms |
10292 KB |
Output is correct |
5 |
Correct |
103 ms |
10028 KB |
Output is correct |
6 |
Correct |
98 ms |
10204 KB |
Output is correct |
7 |
Correct |
99 ms |
10380 KB |
Output is correct |
8 |
Correct |
96 ms |
10304 KB |
Output is correct |
9 |
Correct |
94 ms |
10240 KB |
Output is correct |
10 |
Correct |
309 ms |
15096 KB |
Output is correct |
11 |
Correct |
298 ms |
14972 KB |
Output is correct |
12 |
Correct |
299 ms |
15008 KB |
Output is correct |
13 |
Correct |
303 ms |
14936 KB |
Output is correct |
14 |
Correct |
315 ms |
14944 KB |
Output is correct |
15 |
Correct |
315 ms |
15016 KB |
Output is correct |
16 |
Execution timed out |
1067 ms |
19084 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |