Submission #950480

#TimeUsernameProblemLanguageResultExecution timeMemory
950480starStove (JOI18_stove)C++14
100 / 100
16 ms1904 KiB
#include <bits/stdc++.h> using namespace std; #define N 100005 int n, k, x, y, t, sum; int cha[N];//差 int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> k; cin >> y; for (int i=1;i<n;i++) { x=y; cin >> y; cha[i]=(y-x-1); //cout << "cha " << i << " : " << cha[i] << '\n'; } sort(cha+1,cha+n); sum=n; x=1; while (k<n) { sum+=cha[x]; x++; k++; } cout << sum << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...