# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
501654 |
2022-01-04T09:16:01 Z |
dnaux |
Stove (JOI18_stove) |
C++17 |
|
21 ms |
3200 KB |
#include <bits/stdc++.h>
#define endline "\n"
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define lsb(i) i&(-i)
#define sz(i) (int)i.size()
typedef long long ll;
using namespace std;
const ll INF = 1e18L;
constexpr int mod = int(1e9) + 7;
ll t=1, n, k, cases = 0;
void solve(){
cin >> n >> k;
vector<ll> ar(n),sortar;
for(int i = 0; i < n; i++)cin >> ar[i];
for(int i = 0; i < n - 1; i++){
sortar.pb(ar[i + 1] - ar[i] - 1);
}
sort(sortar.begin(),sortar.end());
ll ans = n;
for(int i = 0; i < n - k; i++){
ans += sortar[i];
}
cout << ans;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
//cin>>t;
for(; cases < t; cases++)solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
316 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
316 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 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 |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
316 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 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 |
16 ms |
3120 KB |
Output is correct |
17 |
Correct |
19 ms |
3120 KB |
Output is correct |
18 |
Correct |
18 ms |
3132 KB |
Output is correct |
19 |
Correct |
19 ms |
3148 KB |
Output is correct |
20 |
Correct |
17 ms |
3136 KB |
Output is correct |
21 |
Correct |
17 ms |
3136 KB |
Output is correct |
22 |
Correct |
19 ms |
3200 KB |
Output is correct |
23 |
Correct |
18 ms |
3132 KB |
Output is correct |
24 |
Correct |
21 ms |
3140 KB |
Output is correct |