Submission #159243

#TimeUsernameProblemLanguageResultExecution timeMemory
159243kimbj0709Stove (JOI18_stove)C++17
100 / 100
86 ms2836 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { int no_of_input,matches; int input; vector<int> vect1; int ans = 0; vector<int> diff; cin >> no_of_input >> matches; for(int i=0;i<no_of_input;i++){ cin >> input; vect1.push_back(input); } for(int i=1;i<no_of_input;i++){ diff.push_back(vect1[i]-vect1[i-1]); } sort(diff.begin(),diff.end()); for(int i=0;i<no_of_input-matches;i++){ ans += diff[i]; } cout << ans+matches; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...