| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1369165 | dragonlyz123 | Stove (JOI18_stove) | C++20 | 11 ms | 1860 KiB |
/*
─────────────────────────────────────────────────────────────────────────────────────
██╗ ███████╗███████╗ ██╗ ██╗███████╗███╗ ██╗ ███████╗███████╗███████╗
██║ ██╔════╝██╔════╝ ╚██╗ ██╔╝██╔══██╗████╗ ██║ ╚══███╔╝██╔════╝██╔════╝
██║ █████╗ █████╗ ╚████╔╝ ███████║██╔██╗ ██║ ███╔╝ █████╗ █████╗
██║ ██╔══╝ ██╔══╝ ╚██╔╝ ██╔══██║██║╚██╗██║ ███╔╝ ██╔══╝ ██╔══╝
███████╗███████╗███████╗ ██║ ██║ ██║██║ ╚████║ ███████╗███████╗███████╗
╚══════╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚══════╝╚══════╝╚══════╝
─────────────────────────────────────────────────────────────────────────────────────
» Stay hungry, stay foolish. «
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll ll_max = 2e18;
ll ll_min = -2e18;
void set_io(string name = "") {
ios_base::sync_with_stdio(0);
cin.tie(0);
if (!name.empty()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
void solve() {
ll n, k; cin >> n >> k;
vector<ll> a(n - 1);
vector<ll> t(n);
cin >> t[0];
for (ll i = 1; i < n; i++) {
cin >> t[i];
a[i - 1] = t[i] - t[i - 1];
}
sort(a.begin(), a.end());
ll ans = n;
for (ll i = 0; i < n - k; i++) {
ans--;
ans += a[i];
}
cout << ans << "\n";
}
int main() {
set_io();
// ll t; cin >> t;
// while (t--) {
// solve();
// }
solve();
return 0;
}
// g++-15 -std=c++23 -O2 solution.cpp -o solution
// ./solution
Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
