#include <stdio.h>
int N,M,A,X[2][10010],x,y;
int main()
{
int i,j,c;
scanf ("%d %d",&N,&M);
for (i=0;i<M;i++){
scanf ("%d %d",&x,&y);
X[0][x]++; X[1][y]++;
}
for (j=0;j<2;j++){
c = 0;
for (i=1;i<=N;i++){
c += X[j][i];
if (c >= (M + 1) / 2) break;
} x = i;
for (i=x-1;i>=1;i--) A += (x - i) * X[j][i];
for (i=x+1;i<=N;i++) A += (i - x) * X[j][i];
}
printf ("%d",A);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
964 KB |
Output is correct |
2 |
Correct |
0 ms |
964 KB |
Output is correct |
3 |
Correct |
0 ms |
964 KB |
Output is correct |
4 |
Correct |
0 ms |
964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
964 KB |
Output is correct |
2 |
Correct |
0 ms |
964 KB |
Output is correct |
3 |
Correct |
0 ms |
964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
964 KB |
Output is correct |
2 |
Correct |
5 ms |
964 KB |
Output is correct |
3 |
Correct |
1 ms |
964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
964 KB |
Output is correct |
2 |
Correct |
8 ms |
964 KB |
Output is correct |
3 |
Correct |
7 ms |
964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
964 KB |
Output is correct |
2 |
Correct |
13 ms |
964 KB |
Output is correct |
3 |
Correct |
18 ms |
964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
964 KB |
Output is correct |
2 |
Correct |
21 ms |
964 KB |
Output is correct |
3 |
Correct |
19 ms |
964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
964 KB |
Output is correct |
2 |
Correct |
18 ms |
964 KB |
Output is correct |
3 |
Correct |
20 ms |
964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
964 KB |
Output is correct |
2 |
Correct |
20 ms |
964 KB |
Output is correct |
3 |
Correct |
23 ms |
964 KB |
Output is correct |