# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1086535 | UNOwen07 | Stove (JOI18_stove) | C++17 | 13 ms | 3064 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;
long long n, k, arr[100005], sum;
priority_queue<long long> q;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
long long tam = n-k;
sum = n;
cin >> arr[1];
for (int i = 2; i <= n; i++){
cin >> arr[i];
long long dif = arr[i]-arr[i-1]-1;
sum += dif;
q.push(dif);
if (q.size() > tam){
sum -= q.top();
q.pop();
}
}
cout << sum;
return 0;
}
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... |