답안 #12789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
12789 2015-01-03T13:26:45 Z woqja125 격자 보존하기 (GA9_preserve) C++
17 / 100
348 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[c-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[c-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[c-i];
		if(t>a) a = t;
	}
	printf("%d", a);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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
5 Correct 0 ms 1868 KB Output is correct
6 Correct 0 ms 1868 KB Output is correct
7 Correct 0 ms 1868 KB Output is correct
8 Correct 0 ms 1868 KB Output is correct
9 Correct 0 ms 1868 KB Output is correct
10 Correct 0 ms 1868 KB Output is correct
11 Correct 0 ms 1868 KB Output is correct
12 Correct 0 ms 1868 KB Output is correct
13 Correct 0 ms 1868 KB Output is correct
14 Correct 0 ms 1868 KB Output is correct
15 Correct 0 ms 1868 KB Output is correct
16 Correct 0 ms 1868 KB Output is correct
17 Correct 0 ms 1868 KB Output is correct
18 Correct 0 ms 1868 KB Output is correct
19 Correct 0 ms 1868 KB Output is correct
20 Correct 0 ms 1868 KB Output is correct
21 Correct 0 ms 1868 KB Output is correct
22 Correct 0 ms 1868 KB Output is correct
23 Correct 0 ms 1868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 348 ms 1864 KB Program hung waiting for input
2 Halted 0 ms 0 KB -