| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1328572 | hahaha | Stove (JOI18_stove) | C++20 | 41 ms | 1556 KiB |
#include <bits/stdc++.h>
using namespace std;
int n,mat;
vector<int> a;
int main()
{ cin>>n>>mat;
for(int i=0; i<n; i++){
int t;
cin>>t;
a.push_back(t);
}
sort(a.begin(), a.end());
vector<int>k;
for(int i=1; i<n; i++)
k.push_back(a[i]-a[i-1]-1);
sort(k.begin(), k.end());
reverse(k.begin(), k.end());
mat=min(mat-1, n);
int i=0;
int ans=a[n-1]+1-a[0];
while(mat--){
ans=ans-k[i++];
}
cout<<ans<<endl;
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
