Submission #516360

#TimeUsernameProblemLanguageResultExecution timeMemory
516360azberjibiouCoin Collecting (JOI19_ho_t4)C++17
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> #define gibon ios::sync_with_stdio(false); cin.tie(0); #define fir first #define sec second #define pdd pair<double, double> #define pii pair<int, int> #define pll pair<ll, ll> #define pmax pair<__int128, __int128> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") typedef long long ll; using namespace std; int dx[4]={0, 1, 0, -1}, dy[4]={1, 0, -1 , 0}; const int mxN=100010; const int mxM=2500000; const int mxK=105; const int MOD=1000000007; const ll INF=8000000000000000001; int N; pll A[2*mxN]; pll B[2*mxN]; ll ans; ll myabs(ll a) { return a>0 ? a : -a; } bool cmp1(pll a, pll b) { return a.fir<b.fir; } bool cmp2(pll a, pll b) { return a.sec<b.sec; } int main() { gibon cin >> N; for(int i=0;i<2*N;i++) cin >> A[i].fir >> A[i].sec; for(int i=0;i<2*N;i++) B[i].fir=i/2+1, B[i].sec=i%2+1; sort(A, A+2*N, cmp1); sort(B, B+2*N, cmp1); for(int i=0;i<2*N;i++) ans+=myabs(A[i].fir-B[i].fir); sort(A, A+2*N, cmp2); sort(B, B+2*N, cmp2); for(int i=0;i<2*N;i++) ans+=myabs(A[i].sec-B[i].sec); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...