#include <stdio.h>
#include <algorithm>
using namespace std;
const int M=100100;
int n,m,x[M],y[M],X,Y;
int s;
int main()
{
int i;
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);
X=x[m/2]; Y=y[m/2];
s=0;
for(i=0;i<m/2;++i)
s+=(X-x[i])+(Y-y[i]);
for(;i<m;++i)
s+=(x[i]-X)+(y[i]-Y);
printf("%d\n",s);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1668 KB |
Output is correct |
2 |
Correct |
0 ms |
1668 KB |
Output is correct |
3 |
Correct |
0 ms |
1668 KB |
Output is correct |
4 |
Correct |
0 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1668 KB |
Output is correct |
2 |
Correct |
0 ms |
1668 KB |
Output is correct |
3 |
Correct |
0 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1668 KB |
Output is correct |
2 |
Correct |
7 ms |
1668 KB |
Output is correct |
3 |
Correct |
1 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1668 KB |
Output is correct |
2 |
Correct |
16 ms |
1668 KB |
Output is correct |
3 |
Correct |
11 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1668 KB |
Output is correct |
2 |
Correct |
20 ms |
1668 KB |
Output is correct |
3 |
Correct |
28 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
1668 KB |
Output is correct |
2 |
Correct |
34 ms |
1668 KB |
Output is correct |
3 |
Correct |
27 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1668 KB |
Output is correct |
2 |
Correct |
32 ms |
1668 KB |
Output is correct |
3 |
Correct |
32 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1668 KB |
Output is correct |
2 |
Correct |
40 ms |
1668 KB |
Output is correct |
3 |
Correct |
38 ms |
1668 KB |
Output is correct |