제출 #1145527

#제출 시각아이디문제언어결과실행 시간메모리
1145527machaca_rodrigoCoin 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();
    int total = 2 * N;
    long[] xs = new long[total];
    long[] ys = new long[total];
    for (int i = 0; i < total; i++) {
      xs[i] = sc.nextLong();
      ys[i] = sc.nextLong();
    }
    Arrays.sort(xs);
    long costX = 0;
    for (int i = 0; i < total; i++) {
      long target = (i / 2) + 1;
      costX += Math.abs(xs[i] - target);
    }
    long baseY = 0;
    int countRow1 = 0;
    for (int i = 0; i < total; i++) {
      if (ys[i] <= 1) {
        baseY += (2 - ys[i]);
        countRow1++;
      } else {
        baseY += (ys[i] - 2);
      }
    }
    long extra = (countRow1 >= N) ? -N : (N - 2L * countRow1);
    long costY = baseY + extra;
    System.out.println(costX + costY);
    sc.close();
  }
}

컴파일 시 표준 에러 (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

=======