Submission #838630

#TimeUsernameProblemLanguageResultExecution timeMemory
838630oscar1fStove (JOI18_stove)C++17
100 / 100
46 ms2504 KiB
#include<bits/stdc++.h> using namespace std; const int MAX_VAL=100*1000+5; int nbVal,nbPossi,rep; int val[MAX_VAL]; vector<int> possi; signed main() { cin>>nbVal>>nbPossi; for (int i=0;i<nbVal;i++) { cin>>val[i]; } for (int i=1;i<nbVal;i++) { possi.push_back(val[i]-val[i-1]-1); } sort(possi.begin(),possi.end()); rep=val[nbVal-1]-val[0]+1; while (nbPossi>1) { rep-=possi.back(); possi.pop_back(); nbPossi--; } cout<<rep<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...