Submission #1033762

#TimeUsernameProblemLanguageResultExecution timeMemory
1033762_shr104Stove (JOI18_stove)C++14
100 / 100
15 ms3544 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define pb push_back #define pf push_front #define fi first #define se second const ll mod = 1e9+7; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("test.inp","r",stdin); freopen("test.out","w",stdout); freopen("test.err","w",stderr); ll n, k; cin >> n >> k; k--; vector<ll> v, a(n); for (ll i = 0; i < n; i++) cin >> a[i]; for (ll i = 1; i < n; i++) v.pb(a[i]-a[i-1]-1); ll ans = a[n-1]-a[0]+1; sort(v.begin(),v.end()); while (k--) {ans -= v.back(); v.pop_back();} cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...