Submission #716741

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

Compilation message (stderr)

stove.java:3: error: class Stove is public, should be declared in a file named Stove.java
public class Stove
       ^
1 error