Submission #12788

# Submission time Handle Problem Language Result Execution time Memory
12788 2015-01-03T13:25:28 Z woqja125 격자 보존하기 (GA9_preserve) C++
0 / 100
360 ms 1868 KB
#include<stdio.h>
#include<algorithm>
int p[100001];
int dat[100010];
int main()
{
	int n, d, k, i, j, c = -1, t, a=0;
	scanf("%d%d%d", &n, &d, &k);
	for(i=1; i<=k; i++)scanf("%d", p+i);
	for(i=1; i<=k; i+=j)
	{
		dat[++c] = p[i] - p[i-1] - 1;
		for(j=0; i+j<=k && p[i]+j == p[i+j]; j++);
	}
	dat[++c] = n-p[k];
	std::sort(dat+1, dat+c);
	a=0;
	for(i=1; i*2<=d && i<c; i++) a += dat[i];
	if(d>=1)
	{
		t=dat[0] > dat[c] ? dat[0]:dat[c];
		for(i=1; i*2+1<=d && i<c; i++) t += dat[i];
		if(t>a) a = t;
	}
	if(d>=2)
	{
		t=dat[0] + dat[c];
		for(i=1; i*2+2<=d && i<c; i++) t += dat[i];
		if(t>a) a = t;
	}
	printf("%d", a);
	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 Incorrect 0 ms 1868 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1868 KB Output is correct
2 Incorrect 0 ms 1868 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 360 ms 1864 KB Program hung waiting for input
2 Halted 0 ms 0 KB -