제출 #1123455

#제출 시각아이디문제언어결과실행 시간메모리
1123455LucaIlieCoin Collecting (JOI19_ho_t4)C++20
0 / 100
0 ms328 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...