Submission #133304

#TimeUsernameProblemLanguageResultExecution timeMemory
133304osaaateiasavtnlCoin Collecting (JOI19_ho_t4)C++14
0 / 100
1080 ms376 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int INF = 1e18 + 7; signed main() { int n; cin >> n; vector <pair <int, int> > a, b; for (int i = 0; i < 2 * n; ++i) { int x, y; cin >> x >> y; a.push_back({x, y}); } for (int i = 1; i <= n; ++i) { b.push_back({i, 1}); b.push_back({i, 2}); } int ans = INF; sort(a.begin(), a.end()); do { int nn = 0; for (int i = 0; i < 2 * n; ++i) { nn += abs(a[i].first - b[i].first) + abs(a[i].second - b[i].second); } ans = min(ans, nn); } while (next_permutation(a.begin(), a.end())); cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...