Submission #931255

#TimeUsernameProblemLanguageResultExecution timeMemory
931255ys2Stove (JOI18_stove)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n, k, prev, cur, ans; vector <int> gaps; signed main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>k; int prev=0; ans=n; for (int i=0; i<n; i++){ int cur; cin>>cur; if ((cur-prev)!=1){ //cout<<cur-prev<<'\n'; gaps.push_back(cur-prev-1); } prev=cur; } int s=gaps.size(); //cout<<s<<'s'; sort(gaps.begin(), gaps.end()); for (int i=0; i<s-k+1; i++){ ans+=gaps[i]; } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...