#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int xar[500005];
int yar[500005];
signed main(){
cin>>n;
for(int i=1;i<=n*2;i++){
cin>>xar[i]>>yar[i];
}
sort(xar+1,xar+n+n+1);
sort(yar+1,yar+n+n+1);
int ans=0;
for(int i=1;i<=n+n;i++){
int pl=(i+1)/2;
ans+=abs(pl-xar[i]);
}
for(int i=1;i<=n;i++){
ans+=abs(yar[i]-1)+abs(yar[i+n]-2);
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |