# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
785118 | Alkarat | Stove (JOI18_stove) | C++14 | 48 ms | 900 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>
using namespace std;
int n,k,x;
long long ans;
priority_queue<int,vector<int>,greater<int>>pq;
int main()
{
cin>>n>>k>>x;
int l=x,r=x+1;
for(int i=2; i<=n; i++)
{
cin>>x;
if(x==r) r=x+1;
else
{
pq.push(x-r);
ans+=r-l;
l=x,r=x+1;
}
}
ans+=r-l;
while(pq.size()>=k)
{
ans+=pq.top();
pq.pop();
}
cout<<ans;
}
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... |