Submission #752605

# Submission time Handle Problem Language Result Execution time Memory
752605 2023-06-03T09:41:50 Z tch1cherin Coin Collecting (JOI19_ho_t4) C++17
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<bool>> used(n, vector<bool>(2, false));
  vector<int> x(2 * n), y(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }
  long long ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (x[i] != INT_MIN && y[i] != INT_MIN) {
      tuple<int, int, int> cur = {INT_MAX, INT_MAX, INT_MAX};
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < 2; k++) {
          if (!used[j][k]) {
            cur = min(cur, {abs(x[i] - j) + abs(y[i] - k), j, k}); 
          }
        }
      }
      used[get<1>(cur)][get<2>(cur)] = true;
      ans += get<0>(cur);
    }
  }
  cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -