# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
915244 | SmuggingSpun | Stove (JOI18_stove) | C++14 | 21 ms | 2528 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>
#define taskname "stove"
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n, k;
cin >> n >> k;
vector<int>t(n);
for(int& x : t){
cin >> x;
}
priority_queue<int>pq;
for(int i = 1; i < n; i++){
pq.push(t[i] - t[i - 1] - 1);
}
int ans = t[n - 1] - t[0] + 1;
for(int i = 1; i < k; i++){
ans -= pq.top();
pq.pop();
}
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... |