| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1203720 | chawinkn | Stove (JOI18_stove) | C++20 | 12 ms | 1480 KiB |
#include <bits/stdc++.h>
using namespace std;
int t[100009];
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> t[i];
int ans=t[n]-t[1]+1;
vector<int> gap;
for (int i = 2; i <= n; i++)
gap.push_back(t[i]-t[i-1]-1);
sort(gap.begin(), gap.end(), greater<int>());
for (int i = 0; i < k-1; i++)
ans -= gap[i];
cout << ans;
// [1,2] *1* [3,4] *2* [6,7]
// [1,7]
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
