Submission #1148056

#TimeUsernameProblemLanguageResultExecution timeMemory
1148056pablo_floresCoin Collecting (JOI19_ho_t4)Java
Compilation error
0 ms0 KiB
import java.util.*; public class joi2019_ho_t4 { static final int MAXN = 100010; static int n; static int[][] mat = new int[MAXN][3]; static long ans = 0; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); readInput(scanner); calculateBalance(); System.out.println(ans); scanner.close(); } private static void readInput(Scanner scanner) { n = scanner.nextInt(); for (int i = 1; i <= 2 * n; i++) { int x = scanner.nextInt(); int y = scanner.nextInt(); processPoint(x, y); } } private static void processPoint(int x, int y) { if (x < 1) { if (y >= 2) { mat[1][2]++; ans += Math.abs(x - 1) + Math.abs(y - 2); } else { mat[1][1]++; ans += Math.abs(x - 1) + Math.abs(y - 1); } } else if (x >= 1 && x <= n) { if (y >= 2) { mat[x][2]++; ans += Math.abs(y - 2); } else { mat[x][1]++; ans += Math.abs(y - 1); } } else if (x > n) { if (y >= 2) { mat[n][2]++; ans += Math.abs(x - n) + Math.abs(y - 2); } else { mat[n][1]++; ans += Math.abs(x - n) + Math.abs(y - 1); } } } private static void calculateBalance() { long num1 = 0, num2 = 0; for (int i = 1; i <= n; i++) { num1 += (mat[i][1] - 1); num2 += (mat[i][2] - 1); balanceColumns(); ans += Math.abs(num1) + Math.abs(num2); } } private static void balanceColumns() { while (num1 > 0 && num2 < 0) { num1--; num2++; ans++; } while (num1 < 0 && num2 > 0) { num1++; num2--; ans++; } } }

Compilation message (stderr)

joi2019_ho_t4.java:75: error: cannot find symbol
        while (num1 > 0 && num2 < 0) {
               ^
  symbol:   variable num1
  location: class joi2019_ho_t4
joi2019_ho_t4.java:75: error: cannot find symbol
        while (num1 > 0 && num2 < 0) {
                           ^
  symbol:   variable num2
  location: class joi2019_ho_t4
joi2019_ho_t4.java:76: error: cannot find symbol
            num1--;
            ^
  symbol:   variable num1
  location: class joi2019_ho_t4
joi2019_ho_t4.java:77: error: cannot find symbol
            num2++;
            ^
  symbol:   variable num2
  location: class joi2019_ho_t4
joi2019_ho_t4.java:80: error: cannot find symbol
        while (num1 < 0 && num2 > 0) {
               ^
  symbol:   variable num1
  location: class joi2019_ho_t4
joi2019_ho_t4.java:80: error: cannot find symbol
        while (num1 < 0 && num2 > 0) {
                           ^
  symbol:   variable num2
  location: class joi2019_ho_t4
joi2019_ho_t4.java:81: error: cannot find symbol
            num1++;
            ^
  symbol:   variable num1
  location: class joi2019_ho_t4
joi2019_ho_t4.java:82: error: cannot find symbol
            num2--;
            ^
  symbol:   variable num2
  location: class joi2019_ho_t4
8 errors

=======