| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1144687 | crispxx | Stove (JOI18_stove) | C++20 | 14 ms | 1480 KiB |
/**
* author: a.k
* created: idk
**/
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define nl '\n'
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k; cin >> n >> k;
vector<int> t(n);
for(auto &u : t) cin >> u;
vector<int> a;
for(int i = 0; i + 1 < n; i++) {
a.pb(t[i + 1] - t[i] - 1);
}
int ans = t[n - 1] - t[0] + 1;
sort(all(a), greater<>());
for(int i = 0; i < k - 1; i++) ans -= a[i];
cout << ans << nl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
