Submission #12135

# Submission time Handle Problem Language Result Execution time Memory
12135 2014-12-21T08:17:52 Z gs13105 격자 보존하기 (GA9_preserve) C++
52 / 100
32 ms 1868 KB
#include <stdio.h>
#include <algorithm>

int arr[100000];
int sor[100000];

inline bool cmp(const int &a,const int &b)
{
	return a>b;
}

inline int mn(int a,int b)
{
	return a<b?a:b;
}

inline int mx(int a,int b)
{
	return a>b?a:b;
}

int main()
{
	int n,k,d,r=0,i;
	scanf("%d%d%d",&n,&k,&d);
	for(i=0;i<k;i++)
		scanf("%d",&arr[i]);
	if(k==1)
	{
		if(d==1)
			printf("%d",mx(arr[0]-1,n-arr[0]));
		else
			printf("%d",n-1);
		return 0;
	}
	if(d>=2*k)
	{
		printf("%d",n-k);
		return 0;
	}
	for(i=0;i<k-1;i++)
		sor[i]=arr[i+1]-arr[i]-1;
	std::sort(sor,sor+k-1,cmp);
	if(d%2)
	{
		for(i=0;i<(d-1)/2;i++)
			r+=sor[i];
		r+=mx(arr[0]-1,n-arr[k-1]);
	}
	else
	{
		for(i=0;i<d/2-1;i++)
			r+=sor[i];
		r+=mx(arr[0]-1+n-arr[k-1],sor[d/2-1]);
	}
	printf("%d",r);
	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
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 Incorrect 0 ms 1868 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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
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 Incorrect 0 ms 1868 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 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
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 Incorrect 0 ms 1868 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 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 24 ms 1868 KB Output is correct
4 Correct 24 ms 1868 KB Output is correct
5 Correct 32 ms 1868 KB Output is correct
6 Correct 32 ms 1868 KB Output is correct
7 Correct 24 ms 1868 KB Output is correct
8 Correct 24 ms 1868 KB Output is correct
9 Correct 8 ms 1868 KB Output is correct
10 Correct 8 ms 1868 KB Output is correct
11 Correct 24 ms 1868 KB Output is correct
12 Correct 32 ms 1868 KB Output is correct
13 Correct 24 ms 1868 KB Output is correct
14 Correct 24 ms 1868 KB Output is correct
15 Correct 28 ms 1868 KB Output is correct
16 Correct 32 ms 1868 KB Output is correct
17 Correct 28 ms 1868 KB Output is correct
18 Correct 28 ms 1868 KB Output is correct
19 Correct 32 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 24 ms 1868 KB Output is correct
23 Correct 28 ms 1868 KB Output is correct
24 Correct 28 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1868 KB Output is correct
2 Correct 12 ms 1868 KB Output is correct
3 Correct 28 ms 1868 KB Output is correct
4 Correct 28 ms 1868 KB Output is correct
5 Correct 24 ms 1868 KB Output is correct
6 Correct 24 ms 1868 KB Output is correct
7 Correct 28 ms 1868 KB Output is correct
8 Correct 32 ms 1868 KB Output is correct
9 Correct 16 ms 1868 KB Output is correct
10 Correct 8 ms 1868 KB Output is correct
11 Correct 24 ms 1868 KB Output is correct
12 Correct 20 ms 1868 KB Output is correct
13 Correct 16 ms 1868 KB Output is correct
14 Correct 16 ms 1868 KB Output is correct
15 Correct 20 ms 1868 KB Output is correct
16 Correct 20 ms 1868 KB Output is correct
17 Correct 12 ms 1868 KB Output is correct
18 Correct 24 ms 1868 KB Output is correct
19 Correct 20 ms 1868 KB Output is correct
20 Correct 4 ms 1868 KB Output is correct