# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1049716 |
2024-08-09T04:26:41 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
344 KB |
#include <bits/stdc++.h>
using namespace std;
//abeke
typedef long long ll;
typedef unsigned long long ull;
#define all(x) x.begin(), x.end()
//#define sz(x) (int)x.size()
#define pb push_back
#define speed ios::sync_with_stdio( false); cin.tie(nullptr); cout.tie(0);
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define eb emplace_back
#define nl '\n'
#define f first
#define s second
#define gcd __gcd
#define ins insert
const int inf = INT_MAX;
const int mod = 1e9+7;
const int N = 2e5+5;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n);
forn (i, n) cin >> a[i];
vector<int> v;
int ans = a[n-1];
for (int i = 1; i < n; i++) {
v.pb(a[i]-a[i-1]-1);
}
sort(all(v));
k--;
for (int i = v.size()-1; i >= 0 && k > 0; i--) {
ans -= v[i];
k--;
} cout << ans << nl;
}
int main()
{
speed;
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |