| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1359793 | trin1506 | Stove (JOI18_stove) | C++20 | 0 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,k;
cin >> n >> k;
vector<ll> a(n);
priority_queue<ll,vector<ll>,greater<ll>> pq;
cin >> a[0];
ll cnt=0;
for(ll i=1;i<n;i++){
cin >> a[i];
if(pq.empty())pq.push(a[i]-a[i-1]-1);
else if(a[i]-a[i-1]-1>pq.top())pq.push(a[i]-a[i-1]-1);
if(pq.size()>k-1)pq.pop();
}
cnt = a[n-1]+1-a[0];
while(!pq.empty()){
ll best = pq.top();
cnt-=best;
pq.pop();
}
cout << cnt;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
