Submission #1115205

#TimeUsernameProblemLanguageResultExecution timeMemory
1115205staszic_ojuzStove (JOI18_stove)C++17
100 / 100
22 ms2040 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, k; cin>>n>>k; vector<long long> vect(n); for (long long i=0;i<n;i++) cin>>vect[i]; sort(vect.begin(), vect.end()); vector<long long> diffs(n-1); for (long long i=0;i<n-1;i++){ diffs[i]=vect[i+1]-vect[i]-1; } sort(diffs.begin(), diffs.end()); long long out=n; for (long long i=0;i<n-k;i++) out+=diffs[i]; cout<<out<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...