Submission #1140463

#TimeUsernameProblemLanguageResultExecution timeMemory
1140463vikofazStove (JOI18_stove)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ // freopen("input","r",stdin); // freopen("output","w",stdout); int n,k; cin >> n >> k; int a, total =0; vector<int> v; for(int i=1; i<=n;i++){ int b; cin >> b; if(i>1){ v.push_back(b-a-1); total += b-a; } a=b; } sort(v.begin(),v.end()); for(int i=0;i<k-1;i++){ total -= v[i]; } cout << total << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...