Submission #1282007

#TimeUsernameProblemLanguageResultExecution timeMemory
1282007okahak71Stove (JOI18_stove)C++20
100 / 100
15 ms2252 KiB
#include <bits/stdc++.h> #define all(X) X.begin(), X.end() #define allr(X) X.rbegin(), X.rend() #define ll long long #define pb push_back #define ins insert #define vec vector using namespace std; const ll N = 2e5 + 5; const ll inf = 1e10; void _(){ ll n, k; cin >> n >> k; vec<ll>a(n); vec<ll>v; for(ll i = 0; i < n; i++){ cin >> a[i]; if(!i) continue ; v.pb(a[i] - a[i - 1] - 1); } ll ans = n; sort(all(v)); for(ll i = 0; i < n - k; i++) ans += v[i]; cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); _(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...