답안 #20974

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20974 2017-03-26T03:50:31 Z undecember 격자 보존하기 (GA9_preserve) C++14
56 / 100
33 ms 2408 KB
#include <bits/stdc++.h>

using namespace std;

int n, k, d;
int mp[2], kp[100005];

int main(void)
{
	scanf("%d%d%d", &n, &k, &d);
	int ans = 0;

	int lp;
	scanf("%d", &lp);
	mp[0] = lp - 1;
	for (int i = 0; i < k - 1; i++)
	{
		scanf("%d", &kp[i]);
		kp[i] = kp[i] - lp - 1;
		lp = kp[i] + lp + 1;
	}
	mp[1] = n - lp;

	sort(mp, mp + 2);
	sort(kp, kp + (k - 1));

	int rst = 2 * k - d;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			int tv = n - k - i * mp[0] - j * mp[1];
			int r = rst - i - j;

			if (r < 0) continue;
			int ki;
			for (ki = 0; r >= 2 && ki < k - 1; ki++)
			{
				tv -= kp[ki];
				r -= 2;
			}
			if (r > k - ki - 1) continue;
			if (r % 2) tv -= kp[ki];

			if (tv > ans) ans = tv;
		}
	}

	printf("%d", ans);
}

Compilation message

preserve.cpp: In function 'int main()':
preserve.cpp:10:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &k, &d);
                             ^
preserve.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &lp);
                  ^
preserve.cpp:18:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &kp[i]);
                      ^

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2408 KB Output is correct
2 Correct 0 ms 2408 KB Output is correct
3 Correct 0 ms 2408 KB Output is correct
4 Correct 0 ms 2408 KB Output is correct
5 Correct 0 ms 2408 KB Output is correct
6 Correct 0 ms 2408 KB Output is correct
7 Correct 0 ms 2408 KB Output is correct
8 Incorrect 0 ms 2408 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2408 KB Output is correct
2 Correct 0 ms 2408 KB Output is correct
3 Correct 0 ms 2408 KB Output is correct
4 Correct 0 ms 2408 KB Output is correct
5 Correct 0 ms 2408 KB Output is correct
6 Correct 0 ms 2408 KB Output is correct
7 Correct 0 ms 2408 KB Output is correct
8 Correct 0 ms 2408 KB Output is correct
9 Correct 0 ms 2408 KB Output is correct
10 Correct 0 ms 2408 KB Output is correct
11 Correct 0 ms 2408 KB Output is correct
12 Correct 0 ms 2408 KB Output is correct
13 Correct 0 ms 2408 KB Output is correct
14 Correct 0 ms 2408 KB Output is correct
15 Correct 0 ms 2408 KB Output is correct
16 Correct 0 ms 2408 KB Output is correct
17 Correct 0 ms 2408 KB Output is correct
18 Correct 0 ms 2408 KB Output is correct
19 Correct 0 ms 2408 KB Output is correct
20 Correct 0 ms 2408 KB Output is correct
21 Correct 0 ms 2408 KB Output is correct
22 Correct 0 ms 2408 KB Output is correct
23 Correct 0 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2408 KB Output is correct
2 Correct 0 ms 2408 KB Output is correct
3 Correct 0 ms 2408 KB Output is correct
4 Correct 0 ms 2408 KB Output is correct
5 Correct 0 ms 2408 KB Output is correct
6 Correct 0 ms 2408 KB Output is correct
7 Correct 0 ms 2408 KB Output is correct
8 Correct 0 ms 2408 KB Output is correct
9 Correct 0 ms 2408 KB Output is correct
10 Correct 0 ms 2408 KB Output is correct
11 Correct 0 ms 2408 KB Output is correct
12 Correct 0 ms 2408 KB Output is correct
13 Correct 0 ms 2408 KB Output is correct
14 Correct 0 ms 2408 KB Output is correct
15 Correct 0 ms 2408 KB Output is correct
16 Correct 0 ms 2408 KB Output is correct
17 Correct 0 ms 2408 KB Output is correct
18 Correct 0 ms 2408 KB Output is correct
19 Correct 0 ms 2408 KB Output is correct
20 Correct 0 ms 2408 KB Output is correct
21 Correct 0 ms 2408 KB Output is correct
22 Correct 0 ms 2408 KB Output is correct
23 Correct 0 ms 2408 KB Output is correct
24 Correct 0 ms 2408 KB Output is correct
25 Correct 0 ms 2408 KB Output is correct
26 Correct 0 ms 2408 KB Output is correct
27 Correct 0 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2408 KB Output is correct
2 Correct 26 ms 2408 KB Output is correct
3 Correct 23 ms 2408 KB Output is correct
4 Correct 29 ms 2408 KB Output is correct
5 Correct 16 ms 2408 KB Output is correct
6 Correct 29 ms 2408 KB Output is correct
7 Correct 26 ms 2408 KB Output is correct
8 Correct 29 ms 2408 KB Output is correct
9 Correct 13 ms 2408 KB Output is correct
10 Correct 3 ms 2408 KB Output is correct
11 Correct 23 ms 2408 KB Output is correct
12 Correct 19 ms 2408 KB Output is correct
13 Correct 26 ms 2408 KB Output is correct
14 Correct 23 ms 2408 KB Output is correct
15 Correct 26 ms 2408 KB Output is correct
16 Correct 33 ms 2408 KB Output is correct
17 Correct 23 ms 2408 KB Output is correct
18 Correct 26 ms 2408 KB Output is correct
19 Correct 26 ms 2408 KB Output is correct
20 Correct 0 ms 2408 KB Output is correct
21 Correct 0 ms 2408 KB Output is correct
22 Correct 23 ms 2408 KB Output is correct
23 Correct 23 ms 2408 KB Output is correct
24 Correct 23 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 2408 KB Output isn't correct
2 Halted 0 ms 0 KB -