# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1155630 | ryan | Stove (JOI18_stove) | Java | 0 ms | 0 KiB |
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int k = scan.nextInt();
Integer arr[] = {1, 2, 5, 6, 8, 11, 13, 15, 16, 20};
Integer dif[] = new Integer[n-1];
for(int i = 0; i < n-1; i++){
dif[i] = arr[i+1] - arr[i]-1;
}
Arrays.sort(dif, Comparator.reverseOrder());
int total = arr[n-1] - arr[0]+1;
for(int i = 0; i<k-1; i++){
total -= dif[i];
}
System.out.println(total);
}
}