# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
467269 |
2021-08-22T10:50:45 Z |
BlancaHM |
Stove (JOI18_stove) |
C++14 |
|
59 ms |
2028 KB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solve(int K, vector<int> & arrivals) {
int N = (int) arrivals.size();
vector<int> gapSizes(N-1);
for (int i = 0; i < N-1; i++)
gapSizes[i] = arrivals[i+1]-arrivals[i]-1;
sort(gapSizes.begin(), gapSizes.end(), greater<int>());
int answer = arrivals[N-1]+1 - arrivals[0];
for (int i = 0; i < K-1; i++) {
answer -= gapSizes[i];
}
return answer;
}
int main() {
int N, K;
vector<int> arrivals;
cin >> N >> K;
arrivals = vector<int>(N);
for (int i = 0; i < N; i++)
cin >> arrivals[i];
cout << solve(K, arrivals) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
292 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
216 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
292 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
216 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
292 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
216 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
53 ms |
1944 KB |
Output is correct |
17 |
Correct |
54 ms |
1988 KB |
Output is correct |
18 |
Correct |
56 ms |
1952 KB |
Output is correct |
19 |
Correct |
56 ms |
2028 KB |
Output is correct |
20 |
Correct |
54 ms |
2020 KB |
Output is correct |
21 |
Correct |
59 ms |
2024 KB |
Output is correct |
22 |
Correct |
54 ms |
1948 KB |
Output is correct |
23 |
Correct |
57 ms |
1948 KB |
Output is correct |
24 |
Correct |
54 ms |
1944 KB |
Output is correct |