#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int first(vector<int>& dist, int num) {
num = min((int)dist.size(), num);
int res = 0;
for (int i=0; i<num; i++) res += dist[i];
return res;
}
int main()
{
int n, k, d;
cin >> n >> k >> d;
vector<int> horse(k);
for (int i=0; i<k; i++) cin >> horse[i];
sort(horse.begin(), horse.end());
int ll = horse[0] - 1;
int rr = n - horse[k-1];
vector<int> dist;
for (int i=0; i<k; i++) dist.push_back(horse[i+1]-horse[i]-1);
sort(dist.rbegin(), dist.rend());
int res = 0;
res = max(res, first(dist, d/2));
res = max(res, max(ll, rr) + first(dist, (d-1)/2));
if (d >= 2) res = max(res, ll + rr + first(dist, d/2-1));
cout << res << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1680 KB |
Output is correct |
2 |
Correct |
0 ms |
1680 KB |
Output is correct |
3 |
Correct |
0 ms |
1680 KB |
Output is correct |
4 |
Correct |
0 ms |
1680 KB |
Output is correct |
5 |
Correct |
0 ms |
1680 KB |
Output is correct |
6 |
Incorrect |
0 ms |
1680 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1680 KB |
Output is correct |
2 |
Correct |
0 ms |
1680 KB |
Output is correct |
3 |
Correct |
0 ms |
1680 KB |
Output is correct |
4 |
Correct |
0 ms |
1680 KB |
Output is correct |
5 |
Correct |
0 ms |
1680 KB |
Output is correct |
6 |
Correct |
0 ms |
1680 KB |
Output is correct |
7 |
Correct |
0 ms |
1680 KB |
Output is correct |
8 |
Correct |
0 ms |
1680 KB |
Output is correct |
9 |
Correct |
0 ms |
1680 KB |
Output is correct |
10 |
Correct |
0 ms |
1680 KB |
Output is correct |
11 |
Correct |
0 ms |
1680 KB |
Output is correct |
12 |
Correct |
0 ms |
1680 KB |
Output is correct |
13 |
Correct |
0 ms |
1680 KB |
Output is correct |
14 |
Correct |
0 ms |
1680 KB |
Output is correct |
15 |
Correct |
0 ms |
1680 KB |
Output is correct |
16 |
Correct |
0 ms |
1680 KB |
Output is correct |
17 |
Correct |
0 ms |
1680 KB |
Output is correct |
18 |
Correct |
0 ms |
1680 KB |
Output is correct |
19 |
Correct |
0 ms |
1680 KB |
Output is correct |
20 |
Correct |
0 ms |
1680 KB |
Output is correct |
21 |
Correct |
0 ms |
1680 KB |
Output is correct |
22 |
Correct |
0 ms |
1680 KB |
Output is correct |
23 |
Correct |
0 ms |
1680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1680 KB |
Output is correct |
2 |
Correct |
0 ms |
1680 KB |
Output is correct |
3 |
Correct |
0 ms |
1680 KB |
Output is correct |
4 |
Correct |
0 ms |
1680 KB |
Output is correct |
5 |
Correct |
0 ms |
1680 KB |
Output is correct |
6 |
Correct |
0 ms |
1680 KB |
Output is correct |
7 |
Correct |
0 ms |
1680 KB |
Output is correct |
8 |
Correct |
0 ms |
1680 KB |
Output is correct |
9 |
Correct |
0 ms |
1680 KB |
Output is correct |
10 |
Correct |
0 ms |
1680 KB |
Output is correct |
11 |
Correct |
0 ms |
1680 KB |
Output is correct |
12 |
Correct |
0 ms |
1680 KB |
Output is correct |
13 |
Correct |
0 ms |
1680 KB |
Output is correct |
14 |
Correct |
0 ms |
1680 KB |
Output is correct |
15 |
Correct |
0 ms |
1680 KB |
Output is correct |
16 |
Correct |
0 ms |
1680 KB |
Output is correct |
17 |
Correct |
0 ms |
1680 KB |
Output is correct |
18 |
Correct |
0 ms |
1680 KB |
Output is correct |
19 |
Correct |
0 ms |
1680 KB |
Output is correct |
20 |
Correct |
0 ms |
1680 KB |
Output is correct |
21 |
Correct |
0 ms |
1680 KB |
Output is correct |
22 |
Correct |
0 ms |
1680 KB |
Output is correct |
23 |
Correct |
0 ms |
1680 KB |
Output is correct |
24 |
Correct |
0 ms |
1680 KB |
Output is correct |
25 |
Correct |
0 ms |
1680 KB |
Output is correct |
26 |
Correct |
0 ms |
1680 KB |
Output is correct |
27 |
Correct |
0 ms |
1680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
2844 KB |
Output is correct |
2 |
Correct |
68 ms |
2844 KB |
Output is correct |
3 |
Correct |
64 ms |
2844 KB |
Output is correct |
4 |
Correct |
60 ms |
2844 KB |
Output is correct |
5 |
Correct |
72 ms |
2844 KB |
Output is correct |
6 |
Correct |
68 ms |
2844 KB |
Output is correct |
7 |
Correct |
72 ms |
2844 KB |
Output is correct |
8 |
Correct |
64 ms |
2844 KB |
Output is correct |
9 |
Correct |
36 ms |
2264 KB |
Output is correct |
10 |
Correct |
16 ms |
1940 KB |
Output is correct |
11 |
Correct |
68 ms |
2828 KB |
Output is correct |
12 |
Correct |
68 ms |
2836 KB |
Output is correct |
13 |
Correct |
64 ms |
2828 KB |
Output is correct |
14 |
Correct |
60 ms |
2836 KB |
Output is correct |
15 |
Correct |
60 ms |
2840 KB |
Output is correct |
16 |
Correct |
72 ms |
2840 KB |
Output is correct |
17 |
Correct |
68 ms |
2832 KB |
Output is correct |
18 |
Correct |
72 ms |
2828 KB |
Output is correct |
19 |
Correct |
60 ms |
2828 KB |
Output is correct |
20 |
Correct |
0 ms |
1680 KB |
Output is correct |
21 |
Correct |
0 ms |
1680 KB |
Output is correct |
22 |
Correct |
68 ms |
2824 KB |
Output is correct |
23 |
Correct |
68 ms |
2836 KB |
Output is correct |
24 |
Correct |
68 ms |
2836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
72 ms |
2844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |