Submission #5208

# Submission time Handle Problem Language Result Execution time Memory
5208 2014-02-16T11:13:11 Z ansol4328 점 모으기 (KOI13_collect) C++
24 / 24
36 ms 1868 KB
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>

int a[100002], b[100002];

int main()
{
    int n, m, sum=0;
    int i, x, y;
    scanf("%d %d",&n,&m);
    for(i=1 ; i<=m ; i++) scanf("%d %d",&a[i],&b[i]);
    std::sort(a+1,a+1+m);
    std::sort(b+1,b+1+m);
    x=a[m/2+m%2], y=b[m/2+m%2];
    for(i=1 ; i<=m ; i++) sum+=abs(a[i]-x)+abs(b[i]-y);
    printf("%d",sum);
    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 8 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 20 ms 1868 KB Output is correct
2 Correct 16 ms 1868 KB Output is correct
3 Correct 24 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 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 16 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1868 KB Output is correct
2 Correct 32 ms 1868 KB Output is correct
3 Correct 36 ms 1868 KB Output is correct