| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1357305 | filipksel | Stove (JOI18_stove) | C++20 | 14 ms | 1472 KiB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,k;
cin >> n >> k;
vector<int> v(n);
for(int i = 0; i < n; i++)
cin >> v[i];
int ans = v[n-1] - v[0] + 1;
priority_queue<int> Q;
for(int i = 1; i < n; i++)
Q.push(v[i] - 1 - v[i-1]);
int Left = k - 1; //-1 because we alreadu used the first match
while(Left--)
{
int x = Q.top();
Q.pop();
ans -= x;
}
cout << ans << "\n";
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
