Submission #927568

#TimeUsernameProblemLanguageResultExecution timeMemory
927568Gromp15Coin Collecting (JOI19_ho_t4)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #define ll long long #define ar array #define db double #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rint(l, r) uniform_int_distribution<int>(l, r)(rng) template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } void test_case() { int n; cin >> n; vector<int> x(2*n), y(2*n); for (int i = 0; i < 2*n; i++) { cin >> x[i] >> y[i]; } sort(all(x)); sort(all(y)); ll ans = 0; for (int i = 0; i < 2*n; i++) { ans += abs(x[i] - (i/2+1)); ans += abs(y[i] - (i / n + 1)); } cout << ans << '\n'; } int main() { cin.tie(0)->sync_with_stdio(0); int t = 1; // cin >> t; while (t--) test_case(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...