| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1309339 | husseinjuanda | Stove (JOI18_stove) | C++20 | 14 ms | 2372 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k; cin >> n >> k;
vector<int> t(n);
for(int i = 0; i < n; i++){
cin >> t[i];
}
int cur = t.back() - t[0] + 1;
vector<int> d;
for(int i = 0; i < n-1; i++){
d.push_back(t[i+1] - t[i] - 1);
}
sort(d.rbegin(), d.rend());
int sz = d.size();
for(int i = 0; i < min(k-1, sz); i++){
cur -= d[i];
}
cout << cur << "\n";
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... | ||||
