| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1346502 | samuelandrianoo_ | Stove (JOI18_stove) | C++20 | 20 ms | 2364 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
ll n, k; cin >> n >> k;
priority_queue<ll> pq;
ll arr[n + 5];
for (ll i = 1; i <= n; i++) cin >> arr[i];
for (ll i = 2; i <= n; i++){
pq.push(arr[i] - arr[i - 1] - 1);
}
ll sisa = k - 1;
set<pair<ll, ll>> st;
ll ans = arr[n] - arr[1] + 1;
while(sisa--){
auto ptr = pq.top(); pq.pop();
ans -= ptr;
}
cout << ans << endl;
}
/*
jadi ini kan or jadi cukup kita cek apakah mungkin kalau di bit
*/| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
