Submission #16240

# Submission time Handle Problem Language Result Execution time Memory
16240 2015-08-18T11:14:18 Z eaststar 점 모으기 (KOI13_collect) C++14
24 / 24
54 ms 1864 KB
#include <stdio.h>
#include <algorithm>
struct data{
	int x,y;
	bool operator<(const data&r)const{
		return x<r.x;
	}
}a[100010];
int main(){
	int i,n,m,s=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)scanf("%d%d",&a[i].x,&a[i].y);
	std::sort(&a[1],&a[m+1]);
	for(i=1;i<=m;++i){
		if(i!=m/2+1){
			s+=abs(a[m/2+1].x-a[i].x);
			std::swap(a[i].x,a[i].y);
		}
	}
	std::swap(a[m/2+1].x,a[m/2+1].y);
	std::sort(&a[1],&a[m+1]);
	for(i=1;i<=m;++i)s+=abs(a[m/2+1].x-a[i].x);
	printf("%d",s);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 0 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1864 KB Output is correct
2 Correct 11 ms 1864 KB Output is correct
3 Correct 4 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1864 KB Output is correct
2 Correct 17 ms 1864 KB Output is correct
3 Correct 4 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1864 KB Output is correct
2 Correct 29 ms 1864 KB Output is correct
3 Correct 23 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1864 KB Output is correct
2 Correct 35 ms 1864 KB Output is correct
3 Correct 32 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 38 ms 1864 KB Output is correct
3 Correct 32 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 1864 KB Output is correct
2 Correct 37 ms 1864 KB Output is correct
3 Correct 32 ms 1864 KB Output is correct