| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1353973 | nxk02102010 | Stove (JOI18_stove) | C++20 | 11 ms | 1860 KiB |
#include<bits/stdc++.h>
using namespace std;
/*
JOI stove
Idea:
*/
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,k;cin >> n >> k;
vector<long long> a(n + 1);
vector<long long> prefix(n + 1);
for(int i = 1;i <= n;i++){
cin >> a[i];
}
int ans = a[n] + 1 - a[1];
for(int i = 1;i <= n - 1;i++){
a[i] = a[i + 1] - 1 - a[i];
}
sort(a.begin() + 1,a.begin() + n,greater<int>());
for(int i = 1;i <= k - 1;i++){
ans -= a[i];
}
cout << ans << '\n';
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
