| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1356301 | cnam9 | Stove (JOI18_stove) | C++20 | 6 ms | 776 KiB |
#include <iostream>
#include <algorithm>
using namespace std;
constexpr int N = 1e5 + 5;
int a[N];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("input.txt", "r", stdin);
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int res = a[n - 1] - a[0] + 1;
for (int i = n - 1; i; i--) {
a[i] -= a[i - 1];
}
nth_element(a + 1, a + k, a + n, greater<int>{});
for (int i = 1; i < k; i++) {
res -= a[i] - 1;
}
cout << res;
return 0;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
