# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
716748 |
2023-03-31T01:30:37 Z |
browntoad |
Stove (JOI18_stove) |
Java 11 |
|
1000 ms |
18092 KB |
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 |
114 ms |
10104 KB |
Output is correct |
2 |
Correct |
124 ms |
10008 KB |
Output is correct |
3 |
Correct |
103 ms |
10188 KB |
Output is correct |
4 |
Correct |
97 ms |
10056 KB |
Output is correct |
5 |
Correct |
103 ms |
10308 KB |
Output is correct |
6 |
Correct |
100 ms |
10144 KB |
Output is correct |
7 |
Correct |
100 ms |
10192 KB |
Output is correct |
8 |
Correct |
104 ms |
10228 KB |
Output is correct |
9 |
Correct |
97 ms |
10340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
10104 KB |
Output is correct |
2 |
Correct |
124 ms |
10008 KB |
Output is correct |
3 |
Correct |
103 ms |
10188 KB |
Output is correct |
4 |
Correct |
97 ms |
10056 KB |
Output is correct |
5 |
Correct |
103 ms |
10308 KB |
Output is correct |
6 |
Correct |
100 ms |
10144 KB |
Output is correct |
7 |
Correct |
100 ms |
10192 KB |
Output is correct |
8 |
Correct |
104 ms |
10228 KB |
Output is correct |
9 |
Correct |
97 ms |
10340 KB |
Output is correct |
10 |
Correct |
305 ms |
14752 KB |
Output is correct |
11 |
Correct |
299 ms |
14896 KB |
Output is correct |
12 |
Correct |
309 ms |
14988 KB |
Output is correct |
13 |
Correct |
307 ms |
14864 KB |
Output is correct |
14 |
Correct |
298 ms |
14860 KB |
Output is correct |
15 |
Correct |
310 ms |
15064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
10104 KB |
Output is correct |
2 |
Correct |
124 ms |
10008 KB |
Output is correct |
3 |
Correct |
103 ms |
10188 KB |
Output is correct |
4 |
Correct |
97 ms |
10056 KB |
Output is correct |
5 |
Correct |
103 ms |
10308 KB |
Output is correct |
6 |
Correct |
100 ms |
10144 KB |
Output is correct |
7 |
Correct |
100 ms |
10192 KB |
Output is correct |
8 |
Correct |
104 ms |
10228 KB |
Output is correct |
9 |
Correct |
97 ms |
10340 KB |
Output is correct |
10 |
Correct |
305 ms |
14752 KB |
Output is correct |
11 |
Correct |
299 ms |
14896 KB |
Output is correct |
12 |
Correct |
309 ms |
14988 KB |
Output is correct |
13 |
Correct |
307 ms |
14864 KB |
Output is correct |
14 |
Correct |
298 ms |
14860 KB |
Output is correct |
15 |
Correct |
310 ms |
15064 KB |
Output is correct |
16 |
Execution timed out |
1070 ms |
18092 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |