Submission #959648

#TimeUsernameProblemLanguageResultExecution timeMemory
959648alo_54Stove (JOI18_stove)C++14
100 / 100
18 ms2524 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int n, k; int times[MAXN]; void opt() { ios_base :: sync_with_stdio(false); cin.tie(nullptr); } int main() { opt(); cin>>n>>k; for (int i = 0; i < n; i++) { cin>>times[i]; } int resp = n; vector <int> difs; for (int i = 1; i < n; i++) { difs.push_back(times[i] - times[i-1] -1); } sort(difs.begin(), difs.end()); for (int i = 0; i < n - k; i++) { resp += difs[i]; } cout<<resp<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...