제출 #1331117

#제출 시각아이디문제언어결과실행 시간메모리
1331117itzsleepyxdStove (JOI18_stove)C++20
100 / 100
14 ms1212 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define aa(v_) v_.begin(),v_.end()

const int mod = 1e9+7;


void sleep(){
    int n,m,k,t,x,y,z,w;
    cin >> n >> m;
    int a[n-1];
    cin >> x;
    for (int i = 0; i < n-1; i++)
    {
        cin >> y;
        a[i]=y-x-1;
        x=y;
    }
    sort(a,a+n-1);
    k=n;
    for (int i = 0; i < n-m; i++)
    {
        k+=a[i];
    }
    cout << k << "\n";
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n=1;
    //cin >> n;
    while (n--) sleep();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...