# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
115969 |
2019-06-10T05:37:28 Z |
oolimry |
Stove (JOI18_stove) |
C++14 |
|
24 ms |
2684 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
//freopen("i.txt","r",stdin);
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> arr;
for(int i = 0;i < n;i++){
int x;
cin >> x;
arr.push_back(x);
}
sort(arr.begin(),arr.end());
vector<int> diff;
for(int i = 1;i < arr.size();i++){
diff.push_back(arr[i] - arr[i-1]);
}
sort(diff.begin(),diff.end());
reverse(diff.begin(),diff.end());
int ans = arr.back() - arr[0];
for(int i = 0;i < k-1;i++){
if(diff[i] <= 1) break;
ans -= (diff[i]);
ans++;
}
ans++;
cout << ans;
return 0;
}
Compilation message
stove.cpp: In function 'int main()':
stove.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1;i < arr.size();i++){
~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
412 KB |
Output is correct |
12 |
Correct |
2 ms |
404 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
412 KB |
Output is correct |
12 |
Correct |
2 ms |
404 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
23 ms |
2564 KB |
Output is correct |
17 |
Correct |
21 ms |
2424 KB |
Output is correct |
18 |
Correct |
23 ms |
2684 KB |
Output is correct |
19 |
Correct |
23 ms |
2556 KB |
Output is correct |
20 |
Correct |
23 ms |
2428 KB |
Output is correct |
21 |
Correct |
23 ms |
2420 KB |
Output is correct |
22 |
Correct |
24 ms |
2548 KB |
Output is correct |
23 |
Correct |
24 ms |
2556 KB |
Output is correct |
24 |
Correct |
23 ms |
2528 KB |
Output is correct |