Submission #20903

# Submission time Handle Problem Language Result Execution time Memory
20903 2017-03-09T06:02:25 Z exqt 격자 보존하기 (GA9_preserve) C++14
100 / 100
66 ms 2804 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <set>
#include <ctime>

using namespace std;


int main()
{
	int n, k, d; cin >> n >> k >> d;
	vector<int> v(k);
	for(int i=0; i<k; i++) cin >> v[i];

	vector<int> gp(k); gp[0] = 0;
	for(int i=0; i<k-1; i++) gp[i+1] = v[i+1]-v[i]-1;

	sort(gp.begin()+1, gp.end());
	reverse(gp.begin()+1, gp.end());

	for(int i=1; i<gp.size(); i++) gp[i] += gp[i-1];

	int g1 = v.front()-1;
	int g2 = n-v.back();

	int res = 0;
	int lim = gp.size()-1;

	res = max(res, gp[min((d  )/2, lim)]);
	if(d >= 2) res = max(res, gp[min((d-2)/2, lim)]+g1+g2);
	res = max(res, gp[min((d-1)/2, lim)]+max(g1, g2));

	cout << res << endl;

    return 0;
}

Compilation message

preserve.cpp: In function 'int main()':
preserve.cpp:24:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1; i<gp.size(); i++) gp[i] += gp[i-1];
                ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
11 Correct 0 ms 2020 KB Output is correct
12 Correct 0 ms 2020 KB Output is correct
13 Correct 0 ms 2020 KB Output is correct
14 Correct 0 ms 2020 KB Output is correct
15 Correct 0 ms 2020 KB Output is correct
16 Correct 0 ms 2020 KB Output is correct
17 Correct 0 ms 2020 KB Output is correct
18 Correct 0 ms 2020 KB Output is correct
19 Correct 0 ms 2020 KB Output is correct
20 Correct 0 ms 2020 KB Output is correct
21 Correct 0 ms 2020 KB Output is correct
22 Correct 0 ms 2020 KB Output is correct
23 Correct 0 ms 2020 KB Output is correct
24 Correct 0 ms 2020 KB Output is correct
25 Correct 0 ms 2020 KB Output is correct
26 Correct 0 ms 2020 KB Output is correct
27 Correct 0 ms 2020 KB Output is correct
28 Correct 0 ms 2020 KB Output is correct
29 Correct 0 ms 2020 KB Output is correct
30 Correct 0 ms 2020 KB Output is correct
31 Correct 0 ms 2020 KB Output is correct
32 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
11 Correct 0 ms 2020 KB Output is correct
12 Correct 0 ms 2020 KB Output is correct
13 Correct 0 ms 2020 KB Output is correct
14 Correct 0 ms 2020 KB Output is correct
15 Correct 0 ms 2020 KB Output is correct
16 Correct 0 ms 2020 KB Output is correct
17 Correct 0 ms 2020 KB Output is correct
18 Correct 0 ms 2020 KB Output is correct
19 Correct 0 ms 2020 KB Output is correct
20 Correct 0 ms 2020 KB Output is correct
21 Correct 0 ms 2020 KB Output is correct
22 Correct 0 ms 2020 KB Output is correct
23 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
11 Correct 0 ms 2020 KB Output is correct
12 Correct 0 ms 2020 KB Output is correct
13 Correct 0 ms 2020 KB Output is correct
14 Correct 0 ms 2020 KB Output is correct
15 Correct 0 ms 2020 KB Output is correct
16 Correct 0 ms 2020 KB Output is correct
17 Correct 0 ms 2020 KB Output is correct
18 Correct 0 ms 2020 KB Output is correct
19 Correct 0 ms 2020 KB Output is correct
20 Correct 0 ms 2020 KB Output is correct
21 Correct 0 ms 2020 KB Output is correct
22 Correct 0 ms 2020 KB Output is correct
23 Correct 0 ms 2020 KB Output is correct
24 Correct 0 ms 2020 KB Output is correct
25 Correct 0 ms 2020 KB Output is correct
26 Correct 0 ms 2020 KB Output is correct
27 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 2804 KB Output is correct
2 Correct 53 ms 2804 KB Output is correct
3 Correct 56 ms 2804 KB Output is correct
4 Correct 59 ms 2804 KB Output is correct
5 Correct 56 ms 2804 KB Output is correct
6 Correct 66 ms 2804 KB Output is correct
7 Correct 63 ms 2804 KB Output is correct
8 Correct 56 ms 2804 KB Output is correct
9 Correct 26 ms 2412 KB Output is correct
10 Correct 16 ms 2212 KB Output is correct
11 Correct 53 ms 2772 KB Output is correct
12 Correct 53 ms 2788 KB Output is correct
13 Correct 56 ms 2772 KB Output is correct
14 Correct 53 ms 2788 KB Output is correct
15 Correct 43 ms 2796 KB Output is correct
16 Correct 56 ms 2796 KB Output is correct
17 Correct 49 ms 2780 KB Output is correct
18 Correct 53 ms 2772 KB Output is correct
19 Correct 53 ms 2772 KB Output is correct
20 Correct 0 ms 2020 KB Output is correct
21 Correct 0 ms 2020 KB Output is correct
22 Correct 53 ms 2764 KB Output is correct
23 Correct 56 ms 2788 KB Output is correct
24 Correct 46 ms 2788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 2804 KB Output is correct
2 Correct 66 ms 2804 KB Output is correct
3 Correct 49 ms 2804 KB Output is correct
4 Correct 46 ms 2804 KB Output is correct
5 Correct 53 ms 2804 KB Output is correct
6 Correct 49 ms 2804 KB Output is correct
7 Correct 53 ms 2804 KB Output is correct
8 Correct 63 ms 2804 KB Output is correct
9 Correct 26 ms 2412 KB Output is correct
10 Correct 13 ms 2212 KB Output is correct
11 Correct 33 ms 2572 KB Output is correct
12 Correct 33 ms 2628 KB Output is correct
13 Correct 56 ms 2644 KB Output is correct
14 Correct 56 ms 2636 KB Output is correct
15 Correct 29 ms 2652 KB Output is correct
16 Correct 43 ms 2700 KB Output is correct
17 Correct 49 ms 2756 KB Output is correct
18 Correct 39 ms 2724 KB Output is correct
19 Correct 39 ms 2620 KB Output is correct
20 Correct 46 ms 2740 KB Output is correct