# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
281826 | BeanZ | Stove (JOI18_stove) | C++14 | 32 ms | 3324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
ll a[100005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("VietCT.INP", "r")){
freopen("VietCT.INP", "r", stdin);
freopen("VietCT.OUT", "w", stdout);
}
ll n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> a[i];
ll ans = a[n] - a[1] + 1;
k--;
priority_queue<ll> pq;
for (int i = 2; i <= n; i++){
pq.push(a[i] - a[i - 1] - 1);
}
while (k){
ans -= pq.top();
pq.pop();
k--;
}
cout << ans;
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |