| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1181635 | rythm_of_knight | Stove (JOI18_stove) | C++17 | 12 ms | 1480 KiB |
#include <bits/stdc++.h>
#define ar array
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, k;
cin >> n >> k;
vector <int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
if (n == k)
return cout << n, 0;
vector <int> b;
int ans = k;
for (int i = 1; i < n; i++)
b.push_back(a[i] - a[i - 1]);
sort(all(b), greater<int>());
for (int i = k - 1; i + 1 < n; i++)
ans += b[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... | ||||
