#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
int a[100002], b[100002];
int main()
{
int n, m, sum=0;
int i, x, y;
scanf("%d %d",&n,&m);
for(i=1 ; i<=m ; i++) scanf("%d %d",&a[i],&b[i]);
std::sort(a+1,a+1+m);
std::sort(b+1,b+1+m);
x=a[m/2+m%2], y=b[m/2+m%2];
for(i=1 ; i<=m ; i++) sum+=abs(a[i]-x)+abs(b[i]-y);
printf("%d",sum);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1868 KB |
Output is correct |
2 |
Correct |
0 ms |
1868 KB |
Output is correct |
3 |
Correct |
0 ms |
1868 KB |
Output is correct |
4 |
Correct |
0 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1868 KB |
Output is correct |
2 |
Correct |
0 ms |
1868 KB |
Output is correct |
3 |
Correct |
0 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1868 KB |
Output is correct |
2 |
Correct |
4 ms |
1868 KB |
Output is correct |
3 |
Correct |
0 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1868 KB |
Output is correct |
2 |
Correct |
16 ms |
1868 KB |
Output is correct |
3 |
Correct |
8 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
1868 KB |
Output is correct |
2 |
Correct |
16 ms |
1868 KB |
Output is correct |
3 |
Correct |
24 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
1868 KB |
Output is correct |
2 |
Correct |
36 ms |
1868 KB |
Output is correct |
3 |
Correct |
24 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1868 KB |
Output is correct |
2 |
Correct |
32 ms |
1868 KB |
Output is correct |
3 |
Correct |
16 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
1868 KB |
Output is correct |
2 |
Correct |
32 ms |
1868 KB |
Output is correct |
3 |
Correct |
36 ms |
1868 KB |
Output is correct |