Submission #233612

#TimeUsernameProblemLanguageResultExecution timeMemory
233612triple_faultStove (JOI18_stove)C++14
100 / 100
30 ms3192 KiB
/* fucking change this 2020 */

#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <random>

#define ll long long

using namespace std;

int main(void) {
    ll n, k; scanf("%lld %lld", &n, &k);
    ll vals[n];
    for (ll i = 0; i < n; ++i) scanf("%lld", &vals[i]);

    vector<ll> dif;
    for (ll i = 1; i < n; ++i) dif.push_back(vals[i] - vals[i - 1] - 1);

    ll ans = n;
    sort(dif.begin(), dif.end());

    for (ll i = 0; i < (n - k); ++i) ans += dif[i];
    printf("%lld\n", ans);
    return 0;
}

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:17:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     ll n, k; scanf("%lld %lld", &n, &k);
              ~~~~~^~~~~~~~~~~~~~~~~~~~~
stove.cpp:19:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (ll i = 0; i < n; ++i) scanf("%lld", &vals[i]);
                                ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...