Submission #127569

#TimeUsernameProblemLanguageResultExecution timeMemory
127569minhcoolStove (JOI18_stove)C++17
100 / 100
88 ms2928 KiB
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> i; int n, m, k, b[100001], tmp; bool ck[100005]; vector<i> a; int main(){ cin >> n >> k; //cout << n << endl; tmp = k; for(int i = 1; i <= n; i++){ cin >> b[i]; //cout << b[i] << endl; } for(int i = 1; i < n; i++) a.push_back(make_pair(b[i + 1] - b[i], i)); sort(a.begin(), a.end()); //cout << ans << endl; int cnt = n; for(int i = 0; i < n - k; i++){ cnt += a[i].first - 1; //cout << cnt << endl; } cout << cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...