| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1341549 | Nipphitch | Stove (JOI18_stove) | C++20 | 19 ms | 2120 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
int n,m,a[N],ans;
priority_queue <int,vector <int>,greater <int>> pq;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
ans=n;
for(int i=1;i<=n;i++){
cin >> a[i];
if(i>1) pq.push({a[i]-(a[i-1]+1)});
}
for(int i=1;i<=n-m && !pq.empty();i++){
ans+=pq.top();
pq.pop();
}
cout << ans;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
