#include<stdio.h>
#include<algorithm>
using namespace std;
int n, m;
int x[100004];
int 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]);
}
sort(x,x+m);sort(y,y+m);
for(i=0;i<m;i++)
{
p+=abs(x[i]-x[m/2]) + abs(y[i]-y[m/2]);
}
printf("%d",p);
}
# |
결과 |
실행 시간 |
메모리 |
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 |
0 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1868 KB |
Output is correct |
2 |
Correct |
16 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 |
20 ms |
1868 KB |
Output is correct |
3 |
Correct |
28 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 |
24 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 |
28 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
1868 KB |
Output is correct |
2 |
Correct |
32 ms |
1868 KB |
Output is correct |
3 |
Correct |
36 ms |
1868 KB |
Output is correct |