# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
198771 |
2020-01-27T15:11:51 Z |
AaronNaidu |
Stove (JOI18_stove) |
C++14 |
|
39 ms |
1556 KB |
#include <bits/stdc++.h>
using namespace std;
int n, k, a, totalSum;
vector<int> arrivals;
vector<int> diffs;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a;
arrivals.push_back(a);
}
totalSum = arrivals[n-1] - arrivals[0] + 1;
for (int i = 1; i < n; i++) {
diffs.push_back(arrivals[i] - arrivals[i-1] -1);
}
sort(diffs.begin(), diffs.end());
for (int i = n-2; i > n-1-k; i--) {
totalSum -= diffs[i];
}
cout << totalSum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
7 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
6 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
7 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
6 ms |
376 KB |
Output is correct |
16 |
Correct |
31 ms |
1524 KB |
Output is correct |
17 |
Correct |
39 ms |
1524 KB |
Output is correct |
18 |
Correct |
29 ms |
1524 KB |
Output is correct |
19 |
Correct |
38 ms |
1556 KB |
Output is correct |
20 |
Correct |
32 ms |
1524 KB |
Output is correct |
21 |
Correct |
30 ms |
1516 KB |
Output is correct |
22 |
Correct |
29 ms |
1524 KB |
Output is correct |
23 |
Correct |
29 ms |
1528 KB |
Output is correct |
24 |
Correct |
29 ms |
1524 KB |
Output is correct |