#include <cstdio>
#include <algorithm>
#include <cstdlib>
int x[100000],y[100000];
int main(){
int m,n;
scanf("%d %d",&m,&n);
for (int i=0; i<n; i++) {
scanf("%d %d",&x[i],&y[i]);
}
std::sort(x,x+n);
std::sort(y,y+n);
int px=x[n/2],py=y[n/2],res=0;
for (int i=0; i<n; i++) {
res+=abs(px-x[i])+abs(py-y[i]);
}
printf("%d",res);
}
# |
결과 |
실행 시간 |
메모리 |
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 |
8 ms |
1868 KB |
Output is correct |
3 |
Correct |
4 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1868 KB |
Output is correct |
2 |
Correct |
8 ms |
1868 KB |
Output is correct |
3 |
Correct |
12 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 |
28 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
1868 KB |
Output is correct |
2 |
Correct |
28 ms |
1868 KB |
Output is correct |
3 |
Correct |
20 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1868 KB |
Output is correct |
2 |
Correct |
28 ms |
1868 KB |
Output is correct |
3 |
Correct |
24 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
1868 KB |
Output is correct |
2 |
Correct |
36 ms |
1868 KB |
Output is correct |
3 |
Correct |
28 ms |
1868 KB |
Output is correct |