Submission #298737

#TimeUsernameProblemLanguageResultExecution timeMemory
298737AmineTrabelsiStove (JOI18_stove)C++14
100 / 100
95 ms1928 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define sz(x) ((int)x.size()) const ll maxint=2e18; const ll minint =-2e18; /*******\ (͡ ° ͜ʖ ͡ °): Hi, relax. \* */ int main(){ int n,k,f; cin>>n>>k>>f; vector<int> v; for(int i=1;i<n;i++){ int x; cin>>x; v.push_back(x-f-1); f=x; } sort(v.begin(),v.end()); int res = n; for(int i=0;i<n-k;i++){ res += v[i]; } cout<<res<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...