| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1114763 | Isa2011 | Stove (JOI18_stove) | C++14 | 26 ms | 2040 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
int h = n - k;
if (n == k) cout << n;
else if (k == 1) cout << a[n-1];
else
{
vector<int> l(n-1);
for (int i = 0; i < n-1; i++) l[i] = a[i+1] - a[i];
sort(l.begin(), l.end());
int ans = n - h;
for (int i = 0; i < h; i++) ans += l[i];
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... | ||||
