Submission #755088

#TimeUsernameProblemLanguageResultExecution timeMemory
755088otiko_lagadzeStove (JOI18_stove)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #define ll long long #define pb push_back #define endl '\n' #define y1 y21 using namespace std; const int inf = 1e9; const int mxn = 2*1e5+11; const int lg = 31; const ll mod = 1e9+7; void slve(){ int n,k; cin>>n>>k; vector<int> a(n), b; for(int i=0; i<n; i++){ cin>>a[i]; if(i){ b.pb(a[i] - a[i-1] - 1); } } int ans = a.back(); sort(b.rbegin(), b.rend()); for(int i=0; i<k-1; i++){ ans -= b[i]; } cout<<ans; } int32_t main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); ll T = 1; // cin>>T; while (T--) { slve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...