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;
using ll = long long;
struct pos{
ll x,y;
bool operator<(const pos &o) const{
return x<o.x;
}
};
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n;
cin >> n;
vector<pos> a(n*2);
for(pos &o : a) cin >> o.x >> o.y;
sort(a.begin(),a.end());
ll ans = 0;
for(ll i = 0;i<n;i++){
pos u = a[i<<1],v = a[i<<1|1];
ans += abs((i+1)-u.x)+abs((i+1)-v.x);
ans += abs(max(u.y,v.y)-2)+abs(min(u.y,v.y)-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... |