Submission #724944

#TimeUsernameProblemLanguageResultExecution timeMemory
724944fdnfksdCoin Collecting (JOI19_ho_t4)C++14
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<int,int> #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=2e5; const ll inf=1e18; const ll mod=1e9+7; ll a[maxN],b[maxN]; ll n,ans=0; void solve() { cin >> n; for(int i=1;i<=2*n;i++) cin >> a[i] >> b[i]; sort(a+1,a+2*n+1); sort(b+1,b+2*n+1); for(int i=1;i<=n;i++) { ans+=abs(b[i]-1); ans+=abs(b[i+n]-2); ans+=abs(a[i*2]-i)+abs(a[i*2-1]-i); } cout << ans; } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...