Submission #20975

# Submission time Handle Problem Language Result Execution time Memory
20975 2017-03-26T03:52:08 Z undecember 격자 보존하기 (GA9_preserve) C++14
100 / 100
39 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;

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

			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]);
                      ^

# Verdict Execution time Memory 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
28 Correct 0 ms 2408 KB Output is correct
29 Correct 0 ms 2408 KB Output is correct
30 Correct 0 ms 2408 KB Output is correct
31 Correct 0 ms 2408 KB Output is correct
32 Correct 0 ms 2408 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2408 KB Output is correct
2 Correct 33 ms 2408 KB Output is correct
3 Correct 23 ms 2408 KB Output is correct
4 Correct 26 ms 2408 KB Output is correct
5 Correct 26 ms 2408 KB Output is correct
6 Correct 26 ms 2408 KB Output is correct
7 Correct 19 ms 2408 KB Output is correct
8 Correct 23 ms 2408 KB Output is correct
9 Correct 13 ms 2408 KB Output is correct
10 Correct 13 ms 2408 KB Output is correct
11 Correct 16 ms 2408 KB Output is correct
12 Correct 23 ms 2408 KB Output is correct
13 Correct 23 ms 2408 KB Output is correct
14 Correct 23 ms 2408 KB Output is correct
15 Correct 23 ms 2408 KB Output is correct
16 Correct 23 ms 2408 KB Output is correct
17 Correct 19 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 19 ms 2408 KB Output is correct
23 Correct 29 ms 2408 KB Output is correct
24 Correct 19 ms 2408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2408 KB Output is correct
2 Correct 23 ms 2408 KB Output is correct
3 Correct 29 ms 2408 KB Output is correct
4 Correct 29 ms 2408 KB Output is correct
5 Correct 23 ms 2408 KB Output is correct
6 Correct 36 ms 2408 KB Output is correct
7 Correct 26 ms 2408 KB Output is correct
8 Correct 26 ms 2408 KB Output is correct
9 Correct 13 ms 2408 KB Output is correct
10 Correct 6 ms 2408 KB Output is correct
11 Correct 19 ms 2408 KB Output is correct
12 Correct 16 ms 2408 KB Output is correct
13 Correct 19 ms 2408 KB Output is correct
14 Correct 16 ms 2408 KB Output is correct
15 Correct 16 ms 2408 KB Output is correct
16 Correct 13 ms 2408 KB Output is correct
17 Correct 19 ms 2408 KB Output is correct
18 Correct 16 ms 2408 KB Output is correct
19 Correct 23 ms 2408 KB Output is correct
20 Correct 23 ms 2408 KB Output is correct