Submission #1332217

#TimeUsernameProblemLanguageResultExecution timeMemory
1332217noobsolver24Stove (JOI18_stove)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "algo/debug.h"
#endif
using namespace std;
#define int long long 
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int sz = 2e5 + 5, inf = 1e18, mod = 1e9 + 7;

int a[sz];

void _(){
    int n, k;
    cin >> n >> k;
    vector<int> d;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (i > 1) d.push_back(a[i] - a[i - 1]);
    }
    sort(all(d));
    if (n == k) {
        cout << k << endl;
        return;
    }
    if (k == 1) {
        cout << a[n] << endl;
        return;
    }
    int ans = k, c = n - k;
    for (auto x : d) {
        if (c > 0) {
            ans += x;
            c--;
        } else break;
    }
    cout << ans << endl;
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    int T = 1;
    // cin >> T;
    while (T--) _();
}

Compilation message (stderr)

stove.cpp:3:10: fatal error: algo/debug.h: No such file or directory
    3 | #include "algo/debug.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.