Submission #67552402
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#define LL long long
LL n,m,a[500010];
int main(){
cin >> n >> m;
priority_queue<LL> q;
for(int i=1;i<=n;i++){
cin >> a[i];
}
sort(a+1,a+1+n);
for(int i=1;i<n;i++) {
q.push(a[i+1]-a[i]);
}
while (m>1){
m--;
if(!q.empty()) q.pop();
}
LL ans = 0;
while (!q.empty()){
ans += q.top();
q.pop();
}
cout << ans;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Transmission Mission |
| User | stone0629 |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 491 Byte |
| Status | AC |
| Exec Time | 240 ms |
| Memory | 11224 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 | 3456 KiB |
| 00-sample-02.txt | AC | 1 ms | 3364 KiB |
| 00-sample-03.txt | AC | 1 ms | 3432 KiB |
| 01-01.txt | AC | 1 ms | 3484 KiB |
| 01-02.txt | AC | 1 ms | 3520 KiB |
| 01-03.txt | AC | 1 ms | 3484 KiB |
| 01-04.txt | AC | 1 ms | 3360 KiB |
| 01-05.txt | AC | 1 ms | 3440 KiB |
| 01-06.txt | AC | 1 ms | 3528 KiB |
| 01-07.txt | AC | 186 ms | 11224 KiB |
| 01-08.txt | AC | 164 ms | 11192 KiB |
| 01-09.txt | AC | 205 ms | 11100 KiB |
| 01-10.txt | AC | 153 ms | 10080 KiB |
| 01-11.txt | AC | 213 ms | 11212 KiB |
| 01-12.txt | AC | 125 ms | 9320 KiB |
| 01-13.txt | AC | 240 ms | 11192 KiB |
| 01-14.txt | AC | 148 ms | 9800 KiB |
| 01-15.txt | AC | 209 ms | 11208 KiB |