Submission #437168

#TimeUsernameProblemLanguageResultExecution timeMemory
437168skybergStove (JOI18_stove)C++17
0 / 100
1 ms288 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int>d; bool comp(int a, int b){ return a > b; } int main() { int n, k; long long int sumd; cin >> n >> k; int a; cin >> a; sumd = a; 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...