| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1131431 | YouKnowCipher | Stove (JOI18_stove) | C++20 | 17 ms | 2376 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve () {
int n, k;
cin >> n >> k;
vector<int> v(n), res;
for (int &i : v) cin >> i;
for (int i = 0; i < n - 1; i++) {
res.push_back(v[i + 1] - v[i] - 1);
}
sort(res.begin(), res.end(), greater<int>());
if (n == k) cout << n;
else {
int val = 0;
for (int i = 0; i < k - 1; i++) {
val += res[i];
}
cout << v.back() + 1 - v.front() - val;
}
}
int32_t main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
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... | ||||
