Submission #20896

# Submission time Handle Problem Language Result Execution time Memory
20896 2017-03-09T05:26:45 Z exqt 격자 보존하기 (GA9_preserve) C++14
0 / 100
63 ms 3264 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;
	for(int i=0; i<k-1; i++) gp.push_back(max(v[i+1]-v[i]-1, 0));

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

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

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

	int res = min(d, 1)*max(g1, g2);
	int lim = gp.size();

	if(d >= 2 && d/2-1 < gp.size()) res = max(res, gp[d/2-1]);
	if(d >= 4 && (d-2)/2-1 < gp.size()) res = max(res, gp[(d-2)/2-1]+g1+g2);
	if(d >= 3 && (d-1)/2-1 < gp.size()) res = max(res, gp[(d-1)/2-1]+g1);
	if(d >= 3 && (d-1)/2-1 < gp.size()) res = max(res, gp[(d-1)/2-1]+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];
                ^
preserve.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(d >= 2 && d/2-1 < gp.size()) res = max(res, gp[d/2-1]);
                     ^
preserve.cpp:33:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(d >= 4 && (d-2)/2-1 < gp.size()) res = max(res, gp[(d-2)/2-1]+g1+g2);
                         ^
preserve.cpp:34:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(d >= 3 && (d-1)/2-1 < gp.size()) res = max(res, gp[(d-1)/2-1]+g1);
                         ^
preserve.cpp:35:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(d >= 3 && (d-1)/2-1 < gp.size()) res = max(res, gp[(d-1)/2-1]+g2);
                         ^
preserve.cpp:30:6: warning: unused variable 'lim' [-Wunused-variable]
  int lim = gp.size();
      ^
# 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 Incorrect 0 ms 2020 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 2020 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 3264 KB Output is correct
2 Correct 56 ms 3264 KB Output is correct
3 Correct 53 ms 3264 KB Output is correct
4 Correct 49 ms 3264 KB Output is correct
5 Correct 53 ms 3264 KB Output is correct
6 Correct 49 ms 3264 KB Output is correct
7 Correct 49 ms 3264 KB Output is correct
8 Incorrect 53 ms 3264 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 3264 KB Output isn't correct
2 Halted 0 ms 0 KB -