Submission #842101

#TimeUsernameProblemLanguageResultExecution timeMemory
842101matthewhutamaStove (JOI18_stove)C++14
100 / 100
35 ms3288 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, k; ll a[100005]; vector <ll> v; int main(){ cin >> n >> k; for (int i = 1; i <= n; i++){ cin >> a[i]; if (i > 1){ v.push_back(a[i] - a[i - 1]); } } sort(v.begin(), v.end()); ll ans = 0; for (int i = 0; i < n - k; i++){ ans += v[i]; } cout << ans + k; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...