# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125957 | EntityIT | Coin Collecting (JOI19_ho_t4) | C++14 | 2 ms | 380 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 5;
int n, x[N << 1], y[N << 1], cnt[2], z[N << 1];
long long ans;
int main () {
scanf("%d", &n);
for (int i = 1; i <= (n << 1); ++i) scanf("%d %d", x + i, y + i), z[i] = (i + 1) / 2;
for (int i = 1; i <= (n << 1); ++i) {
if (y[i] < 2) ans += 1 - y[i], ++cnt[0];
else ans += y[i] - 2, ++cnt[1];
}
ans += abs(cnt[0] - cnt[1]) / 2;
sort(x + 1, x + (n << 1) + 1);
for (int i = 1; i <= (n << 1); ++i) ans += abs(x[i] - z[i]);
printf("%lld", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |