# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1172512 | versesrev | Stove (JOI18_stove) | C++20 | 0 ms | 320 KiB |
// 20:56
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
int main () {
int n, k;
std::cin >> n >> k;
std::vector<int> ts(n, 0);
for (int& t : ts) std::cin >> t;
std::vector<int> ds;
std::adjacent_difference(ts.begin(), ts.end(), std::back_inserter(ds));
std::sort(ds.begin() + 1, ds.end(), std::greater<int>());
int ans = ts[n - 1] - ts[0] + 1;
for (int i = 1; i <= k and i < n; ++i) ans -= ds[i];
std::cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |