#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 = max(g1, g2);
int lim = gp.size(); lim = max(lim-1, 0);
if(d >= 2) res = max(res, gp[min(d/2-1, lim)]);
if(d >= 4) res = max(res, gp[min((d-2)/2-1+g1+g2, lim)]);
if(d >= 3) res = max(res, gp[min((d-1)/2-1+g1, lim)]);
if(d >= 3) res = max(res, gp[min((d-1)/2-1+g2, lim)]);
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];
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
56 ms |
3264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
49 ms |
3264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |