제출 #1342700

#제출 시각아이디문제언어결과실행 시간메모리
1342700curious_tigerStove (JOI18_stove)C++20
100 / 100
13 ms1996 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, k; cin >> n >> k;
    ll t[n], d[n-1];
    for (ll i=0; i<n; i++) {
        cin >> t[i];
        if (i>0)
            d[i-1] = t[i] - t[i-1];
    }
    sort(d, d+n-1);
    ll ans = n;
    for (ll i=0; i<n-k; i++) {
        ans += d[i] - 1;
    }
    cout << ans << "\n";

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...