#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int n, m, y[100001], x[100001], ans;
void input(void)
{
int i;
scanf("%d %d",&n,&m);
for(i=1 ; i<=m ; i++)
scanf("%d %d",&y[i],&x[i]);
sort(y+1,y+m+1);
sort(x+1,x+m+1);
}
void process(void)
{
int i;
for(i=1 ; i<=m ; i++)
ans+=abs(y[(m+1)/2]-y[i])+abs(x[(m+1)/2]-x[i]);
}
void output(void)
{
printf("%d",ans);
}
int main(void)
{
input();
process();
output();
return 0;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1868 KB |
Output is correct |
2 |
Correct |
4 ms |
1868 KB |
Output is correct |
3 |
Correct |
0 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1868 KB |
Output is correct |
2 |
Correct |
16 ms |
1868 KB |
Output is correct |
3 |
Correct |
8 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1868 KB |
Output is correct |
2 |
Correct |
24 ms |
1868 KB |
Output is correct |
3 |
Correct |
24 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1868 KB |
Output is correct |
2 |
Correct |
32 ms |
1868 KB |
Output is correct |
3 |
Correct |
28 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1868 KB |
Output is correct |
2 |
Correct |
32 ms |
1868 KB |
Output is correct |
3 |
Correct |
40 ms |
1868 KB |
Output is correct |