제출 #1147943

#제출 시각아이디문제언어결과실행 시간메모리
1147943sossa_abelCoin Collecting (JOI19_ho_t4)Java
컴파일 에러
0 ms0 KiB
import java.io.*;
import java.util.*;

public class Main {
    static class State {
        int x, y;
        int distance;
        
        State(int x, int y, int distance) {
            this.x = x;
            this.y = y;
            this.distance = distance;
        }
    }
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        
        List<int[]> coins = new ArrayList<>();
        for (int i = 0; i < 2 * n; i++) {
            String[] parts = br.readLine().split(" ");
            int x = Integer.parseInt(parts[0]);
            int y = Integer.parseInt(parts[1]);
            coins.add(new int[]{x, y});
        }
        
        long totalMoves = 0;
        boolean[] used = new boolean[2 * n];
        
        for (int x = 1; x <= n; x++) {
            for (int y = 1; y <= 2; y++) {
                int minMoves = Integer.MAX_VALUE;
                int bestCoin = -1;
                
                for (int i = 0; i < 2 * n; i++) {
                    if (!used[i]) {
                        int moves = Math.abs(coins.get(i)[0] - x) + 
                                  Math.abs(coins.get(i)[1] - y);
                        if (moves < minMoves) {
                            minMoves = moves;
                            bestCoin = i;
                        }
                    }
                }
                
                if (bestCoin != -1) {
                    used[bestCoin] = true;
                    totalMoves += minMoves;
                }
            }
        }
        
        System.out.println(totalMoves);
    }
}

컴파일 시 표준 에러 (stderr) 메시지

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

=======