Submission #163372

#TimeUsernameProblemLanguageResultExecution timeMemory
163372KubalionzzaleStove (JOI18_stove)C++14
100 / 100
150 ms6436 KiB
#include <iostream> #include <set> int main() { int n, k; std::cin >> n >> k; int a[100010]; std::multiset<int> seti; long long ans = n; for (int i = 0; i < n; ++i) { std::cin >> a[i]; if (i > 0) seti.insert(a[i] - a[i - 1] - 1); } int cnt = 0; int maxi = n - k; for (auto it : seti) { int val = it; if (cnt >= maxi) break; else { ans += val; ++cnt; } } std::cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...