#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
int n,m;
scanf("%d %d",&n,&m);
int x[m],y[m];
for(int i=0;i<m;i++)
scanf("%d %d",x+i,y+i);
sort(x,x+m);
sort(y,y+m);
int xm=x[m/2],ym=y[m/2];
int sumx=0,sumy=0;
for(int i=0;i<m;i++){
sumx+=abs(xm-x[i]);
sumy+=abs(ym-y[i]);
}
printf("%d",sumx+sumy);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
884 KB |
Output is correct |
2 |
Correct |
0 ms |
884 KB |
Output is correct |
3 |
Correct |
0 ms |
884 KB |
Output is correct |
4 |
Correct |
0 ms |
884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
884 KB |
Output is correct |
2 |
Correct |
0 ms |
884 KB |
Output is correct |
3 |
Correct |
0 ms |
884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
888 KB |
Output is correct |
2 |
Correct |
9 ms |
968 KB |
Output is correct |
3 |
Correct |
2 ms |
884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1040 KB |
Output is correct |
2 |
Correct |
20 ms |
1120 KB |
Output is correct |
3 |
Correct |
15 ms |
1040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1200 KB |
Output is correct |
2 |
Correct |
27 ms |
1280 KB |
Output is correct |
3 |
Correct |
32 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
1516 KB |
Output is correct |
2 |
Correct |
44 ms |
1516 KB |
Output is correct |
3 |
Correct |
33 ms |
1508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
884 KB |
Output is correct |
2 |
Correct |
37 ms |
1432 KB |
Output is correct |
3 |
Correct |
41 ms |
1592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
1592 KB |
Output is correct |
2 |
Correct |
50 ms |
1592 KB |
Output is correct |
3 |
Correct |
46 ms |
1592 KB |
Output is correct |