# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
293056 |
2020-09-07T15:52:04 Z |
dolijan |
Stove (JOI18_stove) |
C++14 |
|
97 ms |
3312 KB |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
ll n,k;
cin>>n>>k;
ll a[n];
for(int i=0;i<n;i++) cin>>a[i];
vector<ll> diff;
for(int i=1;i<n;i++) diff.push_back(a[i]-a[i-1]);
sort(diff.begin(),diff.end());
ll kolko=0;
k--;
for(int i=diff.size()-1;i>=(int)diff.size()-k;i--) kolko+=diff[i];
kolko=((a[n-1]-a[0])-kolko);
kolko+=(k+1);
cout<<kolko<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
512 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
512 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
95 ms |
3184 KB |
Output is correct |
17 |
Correct |
95 ms |
3188 KB |
Output is correct |
18 |
Correct |
97 ms |
3220 KB |
Output is correct |
19 |
Correct |
93 ms |
3232 KB |
Output is correct |
20 |
Correct |
93 ms |
3192 KB |
Output is correct |
21 |
Correct |
94 ms |
3172 KB |
Output is correct |
22 |
Correct |
96 ms |
3312 KB |
Output is correct |
23 |
Correct |
93 ms |
3312 KB |
Output is correct |
24 |
Correct |
92 ms |
3184 KB |
Output is correct |