| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1123455 | LucaIlie | Coin Collecting (JOI19_ho_t4) | C++20 | 0 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5;
vector<int> v;
int main() {
int n, cnt1 = 0, cnt2 = 0;
long long ans = 0;
cin >> n;
for ( int i = 0; i < 2 * n; i++ ) {
int x, y;
cin >> x >> y;
if ( x < 1 ) {
ans += 1 - x;
x = 1;
} else if ( x > n ) {
ans += x - n;
x = n;
}
if ( y < 1 ) {
ans += 1 - y;
y = 1;
} else if ( y > 2 ) {
ans += y - 2;
y = 2;
}
if ( y == 1 )
cnt1++;
else
cnt2++;
v.push_back( x );
}
ans += abs( cnt1 - cnt2 ) / 2;
sort( v.begin(), v.end() );
for ( int i = 0; i < v.size(); i++ )
ans += abs( v[i] - (i / 2 + 1) );
cout << ans << "\n";
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
