# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
434751 |
2021-06-21T17:17:31 Z |
sikamax2019 |
Stove (JOI18_stove) |
C++14 |
|
28 ms |
2340 KB |
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define _cout(v) for(auto f : v ) cout << f << " " ;
#define _cin(v) for(auto &it : v)cin >> it ;
#define _for(v) for(int i=0;i<(v);i++)
#define vi vector<int>
#define fs first
#define sc second
const int mod =1e9+7;
int32_t main() {
IOS;
int n,k;
cin>>n>>k;
vector<int>a(n);
for(auto &I:a)cin>>I;
sort(all(a));
vi v;
for(int i=1;i<n;i++){
v.pb(a[i]-a[i-1]-1);
}
sort(all(v));
int ans=n;
for(int i=0;i<n-k;i++){
ans+=v[i];
}
cout<<ans;
}
# |
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 |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
204 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 |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 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 |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
23 ms |
2256 KB |
Output is correct |
17 |
Correct |
23 ms |
2236 KB |
Output is correct |
18 |
Correct |
25 ms |
2240 KB |
Output is correct |
19 |
Correct |
24 ms |
2244 KB |
Output is correct |
20 |
Correct |
28 ms |
2236 KB |
Output is correct |
21 |
Correct |
23 ms |
2324 KB |
Output is correct |
22 |
Correct |
23 ms |
2232 KB |
Output is correct |
23 |
Correct |
23 ms |
2256 KB |
Output is correct |
24 |
Correct |
25 ms |
2340 KB |
Output is correct |