49192023-04-07 12:23:29zolmikiVilágnaptár (45 pont)javaForditási hiba
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.sql.Array;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String [] readed = br.readLine().split(" ");
        int N = Integer.parseInt(readed[0]);
        int K = Integer.parseInt(readed[1]);
        int [] heights = new int[N];
        readed = br.readLine().split(" ");
        for(int i = 0; i < N; i++){
            heights[i] = Integer.parseInt(readed[i]);
        }
        br.close();

        ArrayList<Integer> list = new ArrayList<Integer>();

        int startIndex = 0;
        while(startIndex + K <= N){
            int result = 0;
            int [] currentHeights = heights.clone();
            for(int k = 0; k < K; k++){
                for(int i = startIndex + K - 1; i > startIndex; i--){
                    if(currentHeights[i] < currentHeights[i - 1] && Math.abs(currentHeights[i] - currentHeights[i - 1]) == 1){
                        continue;
                    }else if(currentHeights[i] >= currentHeights[i - 1]){
                        int difference = Math.abs(currentHeights[i] - currentHeights[i - 1]) + 1;
                        currentHeights[i - 1] += difference;
                        result += difference;
                    } else {
                        int difference = Math.abs(currentHeights[i] - currentHeights[i - 1]) - 1;
                        currentHeights[i] += difference;
                        result += difference;
                    }

                }
            }
            /*System.out.println(startIndex + "--->" + (startIndex + K - 1));
            System.out.print("[");
            for(int szam : currentHeights){
                System.out.print(szam + ", ");
            }
            System.out.print("\b\b]-->"+ result + "\n");*/
            list.add(result);
            startIndex++;
        }

        int min = Integer.MAX_VALUE;
        for(int i = 0; i < list.size(); i++){
            if(min > list.get(i)){
                min = list.get(i);
            }
        }
        System.out.println(min);
    }
}
Forditási hiba
exit status 1
main.java:6: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error
Exited with error status 1