Submission #752605

#TimeUsernameProblemLanguageResultExecution timeMemory
752605tch1cherinCoin Collecting (JOI19_ho_t4)C++17
0 / 100
1 ms340 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...