| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1228014 | diana | Stove (JOI18_stove) | C++20 | 15 ms | 1476 KiB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n, k; cin >> n >> k;
int a[n];
for(int i=0; i<n; i++)
cin >> a[i];
int sum = a[n-1] - a[0] + 1;
priority_queue<int> pq;
for(int i=1; i<n; i++)
pq.push(a[i] - a[i-1] - 1);
while((--k) && !pq.empty())
{
sum -= pq.top();
pq.pop();
}
cout << sum << '\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... | ||||
