#include<stdio.h>
#include<algorithm>
int n, m;
int x[100004],y[100005];
int p;
int main()
{
int i, j;
scanf("%d %d",&n,&m);
for(i=0; i<m; i++)
scanf("%d %d",&x[i],&y[i]);
std::sort(x,x+m);std::sort(y,y+m);
for(i=0;i<m;i++)
p+=std::abs(x[i]-x[m/2]) + std::abs(y[i]-y[m/2]);
printf("%d",p);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1864 KB |
Output is correct |
2 |
Correct |
0 ms |
1864 KB |
Output is correct |
3 |
Correct |
0 ms |
1864 KB |
Output is correct |
4 |
Correct |
0 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1864 KB |
Output is correct |
2 |
Correct |
0 ms |
1864 KB |
Output is correct |
3 |
Correct |
0 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1864 KB |
Output is correct |
2 |
Correct |
9 ms |
1864 KB |
Output is correct |
3 |
Correct |
4 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
1864 KB |
Output is correct |
2 |
Correct |
18 ms |
1864 KB |
Output is correct |
3 |
Correct |
13 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1864 KB |
Output is correct |
2 |
Correct |
22 ms |
1864 KB |
Output is correct |
3 |
Correct |
31 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
1864 KB |
Output is correct |
2 |
Correct |
36 ms |
1864 KB |
Output is correct |
3 |
Correct |
21 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1864 KB |
Output is correct |
2 |
Correct |
36 ms |
1864 KB |
Output is correct |
3 |
Correct |
40 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
1864 KB |
Output is correct |
2 |
Correct |
42 ms |
1864 KB |
Output is correct |
3 |
Correct |
31 ms |
1864 KB |
Output is correct |