Submission #1250582

#TimeUsernameProblemLanguageResultExecution timeMemory
1250582LaMatematica14Stove (JOI18_stove)C++20
100 / 100
12 ms1096 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int N, K; cin >> N >> K;
    vector<long long> diff(N-1);
    long long t; cin >> t;
    for (int i = 0; i < N-1; i++) {
        long long a; cin >> a;
        diff[i] = a-t-1;
        t = a;
    }
    sort(diff.begin(), diff.end());
    long long tot = N;
    for (int i = 0; i < N-K; i++) tot += diff[i];
    cout << tot << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...