Submission #1147938

#TimeUsernameProblemLanguageResultExecution timeMemory
1147938sossa_abelCoin Collecting (JOI19_ho_t4)C++20
Compilation error
0 ms0 KiB
import java.io.*; import java.util.*; public class CoinCollecting { 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); } }

Compilation message (stderr)

joi2019_ho_t4.cpp:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
joi2019_ho_t4.cpp:1:1: note: C++20 'import' only available with '-fmodules-ts', which is not yet enabled with '-std=c++20'
joi2019_ho_t4.cpp:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
joi2019_ho_t4.cpp:2:1: note: C++20 'import' only available with '-fmodules-ts', which is not yet enabled with '-std=c++20'
joi2019_ho_t4.cpp:4:1: error: expected unqualified-id before 'public'
    4 | public class CoinCollecting {
      | ^~~~~~