Submission #67534629
Source Code Expand
#include<bits/stdc++.h>
#define il inline
#define all(x) (x).begin(),(x).end()
#define mem(x,y) memset((x),(y),sizeof((x)))
#define input(x) freopen(x,"r",stdin)
#define output(x) freopen(x,"w",stdout)
using namespace std;
using db=double;
using ll=long long;
using ull=unsigned long long;
const int N=5e5+10;
ll a[N],b[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;++i) cin>>a[i];
sort(a+1,a+n+1);
n=unique(a+1,a+n+1)-a-1;
ll ans=a[n]-a[1]+1;
for(int i=1;i<n;++i) b[i]=a[i+1]-a[i]-1;
sort(b+1,b+n);
for(int i=n-1;i>=max(1,n-m+1);--i) ans-=b[i];
cout<<max(0ll,ans-m);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Transmission Mission |
| User | ilibilib |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 736 Byte |
| Status | AC |
| Exec Time | 99 ms |
| Memory | 11444 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 1 ms | 3424 KiB |
| 00-sample-02.txt | AC | 1 ms | 3496 KiB |
| 00-sample-03.txt | AC | 1 ms | 3404 KiB |
| 01-01.txt | AC | 1 ms | 3464 KiB |
| 01-02.txt | AC | 1 ms | 3432 KiB |
| 01-03.txt | AC | 1 ms | 3432 KiB |
| 01-04.txt | AC | 1 ms | 3468 KiB |
| 01-05.txt | AC | 1 ms | 3500 KiB |
| 01-06.txt | AC | 1 ms | 3400 KiB |
| 01-07.txt | AC | 36 ms | 7472 KiB |
| 01-08.txt | AC | 41 ms | 11444 KiB |
| 01-09.txt | AC | 73 ms | 11116 KiB |
| 01-10.txt | AC | 54 ms | 9080 KiB |
| 01-11.txt | AC | 76 ms | 11240 KiB |
| 01-12.txt | AC | 51 ms | 7600 KiB |
| 01-13.txt | AC | 99 ms | 11312 KiB |
| 01-14.txt | AC | 61 ms | 8300 KiB |
| 01-15.txt | AC | 77 ms | 11308 KiB |