| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1331104 | kantaponz | Stove (JOI18_stove) | C++20 | 18 ms | 2332 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx = 1e5+5;
int n, k;
ll ans = 0;
ll t[nx];
priority_queue<ll, vector<ll>, greater<ll>> pq;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> t[i];
for (int i = 1; i + 1 <= n; i++) pq.push(t[i+1] - t[i] - 1);
ans = n;
while (n > k) {
ans += pq.top();
n--;
pq.pop();
}
cout << ans;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
