| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1283840 | arashmemar | Stove (JOI18_stove) | C++20 | 36 ms | 1064 KiB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int a[maxn];
int main()
{
int n, k;
cin >> n >> k;
if (n == 1)
{
cout << 1;
return 0;
}
int p, s;
cin >> s;
p = s;
for (int i = 1;i < n;i++)
{
int cur;
cin >> cur;
a[i] = cur - p - 1;
p = cur;
}
int ans = p - s + 1;
sort(a + 1, a + n);
reverse(a + 1, a + n);
for (int i = 1;i < k;i++)
{
ans -= a[i];
}
cout << ans;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
