#include <stdio.h>
#include "algorithm"
using namespace std;
int x[100000], y[100000];
int main(void)
{
int N, M, i, cx, cy, s = 0;
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);
cx = x[M / 2];
cy = y[M / 2];
for(i = 0; i < M; i++)
{
s += cx > x[i] ? cx - x[i] : x[i] - cx;
s += cy > y[i] ? cy - y[i] : y[i] - cy;
}
printf("%d\n", s);
}
# |
결과 |
실행 시간 |
메모리 |
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 |
12 ms |
1868 KB |
Output is correct |
3 |
Correct |
12 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1868 KB |
Output is correct |
2 |
Correct |
20 ms |
1868 KB |
Output is correct |
3 |
Correct |
20 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
1868 KB |
Output is correct |
2 |
Correct |
36 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 |
32 ms |
1868 KB |
Output is correct |
3 |
Correct |
36 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
1868 KB |
Output is correct |
2 |
Correct |
32 ms |
1868 KB |
Output is correct |
3 |
Correct |
40 ms |
1868 KB |
Output is correct |