Submission #873642

#TimeUsernameProblemLanguageResultExecution timeMemory
873642maxFedorchukStove (JOI18_stove)C++14
100 / 100
33 ms7212 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios_base::sync_with_stdio(0); set < long long > st; long long n,k,a; cin>>n>>k; for(long long i=1;i<=n;i++) { cin>>a; st.insert(a); } long long res=st.size(); vector < long long > vid; long long mun=-1; for(auto u:st) { if(mun!=-1) { vid.push_back(u-(mun+1)); } mun=u; } sort(vid.begin(),vid.end()); long long ndob=st.size()-k; for(long long i=0;i<ndob;i++) { res+=vid[i]; } cout<<res<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...