Submission #347403

#TimeUsernameProblemLanguageResultExecution timeMemory
347403IwanttobreakfreeStove (JOI18_stove)C++14
100 / 100
51 ms2924 KiB
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; long long int N,K,horatotal; int main(){ while(cin>>N>>K){ vector <long long int> horainicio(N); vector <long long int> rangoespera(N-1); for(int a=0;a<N;a++){ cin>>horainicio[a]; } horatotal=horainicio[N-1]-horainicio[0]+1; for(int a=0;a<N-1;a++){ rangoespera[a]=horainicio[a+1]-horainicio[a]-1; } sort(rangoespera.rbegin(),rangoespera.rend()); for(int a=0;a<K-1;a++){ horatotal-=rangoespera[a]; } cout<<horatotal<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...