Submission #159244

#TimeUsernameProblemLanguageResultExecution timeMemory
159244kimbj0709Stove (JOI18_stove)C++17
100 / 100
27 ms2680 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios::sync_with_stdio(0); cin.tie(0); 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...