Submission #437169

#TimeUsernameProblemLanguageResultExecution timeMemory
437169skybergStove (JOI18_stove)C++17
0 / 100
1 ms204 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; vector<long long int>d; bool comp(long long int a,long long int b){ return a > b; } int main() { long long int n, k; long long int sumd; cin >> n >> k; long long int a; cin >> a; sumd = a; long long int b; for(int i = 1; i < n; i++){ cin >> b; d.push_back(b - a - 1); a = b; } sumd = b + 1 - sumd; sort(d.begin(), d.end(), comp); for(int i = 0; i < k - 1; i++){ sumd -= d[i]; } cout << sumd; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...