제출 #1148128

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<int[]> coins = new ArrayList<>();
        for (int i = 0; i < 2 * N; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            coins.add(new int[]{x, y});
        }

        List<int[]> targets = new ArrayList<>();
        for (int x = 1; x <= N; x++) {
            targets.add(new int[]{x, 1});
            targets.add(new int[]{x, 2});
        }

        coins.sort((a, b) -> Integer.compare(a[0], b[0]));
        targets.sort((a, b) -> Integer.compare(a[0], b[0]));

        long totalOps = 0;
        for (int i = 0; i < 2 * N; i++) {
            int[] coin = coins.get(i);
            int[] target = targets.get(i);
            totalOps += Math.abs((long) coin[0] - target[0]) + Math.abs((long) coin[1] - target[1]);
        }

        System.out.println(totalOps);
    }
}

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

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

=======