Submission #203524

#TimeUsernameProblemLanguageResultExecution timeMemory
203524SoGoodStove (JOI18_stove)C++14
100 / 100
77 ms2424 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5+5 , mod = 1e9 +7 ; long long n , m; int main() { cin>>n>>m ; long long l = 0 , t; vector<long long > v; for(int i = 0 ; i<n ; i++) { cin>>t; if(i) { v.push_back( t - l -1 ); } l = t; } long long k = 0; sort(v.begin() , v.end()); for(int i = 0;i<n - m ;i++) k+=v[i]; cout<< n+k; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...