# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
330132 | eric_xiao | Stove (JOI18_stove) | C++14 | 52 ms | 2148 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long A[500000];
vector<ll> te;
int main()
{
ll N,M,i,j,k;
cin >> N >> k;
for(i = 0;i < N;i++)
{
cin >> A[i];
if(i > 0) te.push_back(A[i]-A[i-1]-1);
}
ll ans = A[N-1]-A[0]+1;
sort(te.begin(),te.end());
reverse(te.begin(),te.end());
for(i = 0;i < k-1;i++)
{
ans -= te[i];
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |