Submission #430378

#TimeUsernameProblemLanguageResultExecution timeMemory
430378Drew_Coin Collecting (JOI19_ho_t4)C++17
0 / 100
1 ms204 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> using namespace std; #define ll long long #define ii pair<int, int> #define pl pair<ll, ll> #define f1 first #define s2 second const int MAX = 2e5 + 69; int X[MAX], Y[MAX]; int main() { ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < 2*n; ++i) cin >> X[i] >> Y[i]; sort(X, X + 2*n); sort(Y, Y + 2*n); ll ans = 0; //calculate X coordinate contribution for (int i = 0; i < 2*n; ++i) ans += abs(X[i] - (i/2 + 1)); for (int i = 0; i < 2*n; ++i) ans += abs(Y[i] - (i/n + 1)); cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...