Submission #1115669

#TimeUsernameProblemLanguageResultExecution timeMemory
1115669staszic_ojuzStove (JOI18_stove)C++17
100 / 100
20 ms2512 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,k,m; cin >> n >> k; vector<int>ciag,c2; for(int i=0;i<n;++i){ cin >> m; ciag.push_back(m); } sort(ciag.begin(),ciag.end()); int suma=0; for(int i=0;i<n-1;++i){ c2.push_back(ciag[i+1]-ciag[i]); suma+=ciag[i+1]-ciag[i]; } sort(c2.begin(),c2.end()); /*for(int i=0;i<c2.size();++i){ cout << c2[i] << ' '; } cout << suma << endl; */ for(int i=n-2;i>n-1-k;--i){ suma-=c2[i]-1; } cout << suma+1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...