Submission #891878

#TimeUsernameProblemLanguageResultExecution timeMemory
891878goodspeed0208Stove (JOI18_stove)C++14
100 / 100
34 ms2940 KiB
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<utility> #define int long long #define INF 1000000000000000000 using namespace std; signed main() { int n, k; cin >> n >> k; vector<int>v(n); for (auto &i : v) cin >> i; vector<int>d(n-1); for (int i = 0 ; i < n-1 ; i++) { d[i] = v[i+1] - v[i]; } sort(d.begin(), d.end()); int ans = n; for (int i = 0 ; i < n-k ; i++) { ans += d[i]-1; } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...