| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1241944 | i_lov_aris | Stove (JOI18_stove) | C++20 | 12 ms | 1892 KiB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 100000;
int n, k;
int a[MAXN + 5];
int d[MAXN + 5];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
int total = a[n] + 1 - a[1];
for(int i = 1; i < n; i++){
d[i] = a[i + 1] - a[i] - 1;
}
sort(d + 1, d + n, greater<int>());
int s = 0;
for(int i = 1; i <= k - 1; i++){
s += d[i];
}
cout << total - s;
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... | ||||
