Submission #591995

#TimeUsernameProblemLanguageResultExecution timeMemory
591995ozedStove (JOI18_stove)C++14
100 / 100
45 ms1084 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pi; int main(){ int n,k,out=0; cin>>n>>k; vi v(n); vi gap(n-1); for(int i=0;i<n;i++){ cin>>v[i]; } for(int i=0;i<n-1;i++){ gap[i]=v[i+1]-v[i]-1; } out=v[n-1]+1-v[0]; sort(gap.rbegin(),gap.rend()); for(int i=0;i<k-1;i++){ out-=gap[i]; } cout<<out; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...