Submission #1115197

#TimeUsernameProblemLanguageResultExecution timeMemory
1115197staszic_ojuzStove (JOI18_stove)C++17
100 / 100
43 ms3672 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n,k; cin>>n>>k; vector<long long> t; for(int i = 0;i<n;i++) { long long x; cin>>x; t.push_back(x); } vector<long long> t2; for(int i = 1;i<n;i++) { t2.push_back(t[i]-t[i-1]-1); } sort(t2.begin(),t2.end()); long long ans = n; for(int i = 0;i<n-k;i++) { ans+=t2[i]; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...