| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1331102 | sabishii | Stove (JOI18_stove) | C++20 | 13 ms | 1272 KiB |
#include <bits/stdc++.h>
using namespace std;
int n, k, arr[100010], ans;
int main() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
cin >> n >> k;
vector<int> inte;
for(int i=1; i<=n; i++) {
cin >> arr[i];
}
for(int i=1; i<n; i++) inte.push_back(arr[i+1]-arr[i]-1);
ans = arr[n]-arr[1]+1;
sort(inte.begin(), inte.end(), greater<int>());
for(int i=0; i<min(k-1, (int)inte.size()); i++) {
ans -= inte[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... | ||||
