Submission #1155630

#TimeUsernameProblemLanguageResultExecution timeMemory
1155630ryanStove (JOI18_stove)Java
Compilation error
0 ms0 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); } }

Compilation message (stderr)

stove.java:2: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error

=======