| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1332794 | Zone_zonee | Stove (JOI18_stove) | C++20 | 21 ms | 1224 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int a[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
int t = k-1;
priority_queue<int> pq;
for(int i = 1; i <= n; ++i){
cin >> a[i];
if(i > 1) pq.push(a[i]-a[i-1]);
}
int ans = 0;
while(!pq.empty() && t--){
pq.pop();
ans++;
}
while(!pq.empty()){
ans += pq.top(); pq.pop();
}
cout << ans+1 << '\n';
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
