Submission #744198

#TimeUsernameProblemLanguageResultExecution timeMemory
744198MONStove (JOI18_stove)C++17
100 / 100
54 ms1792 KiB
#include<iostream>
#include<queue>
using namespace std;
using ull = unsigned long long;

int main()
{
    int n,k,last,x; cin >> n >> k >> last; ull ans = last; k--;
    priority_queue<int> pq;
    for(int i = 2; i <= n ; i++)
        {
            cin >> x; pq.push(x - last - 1);
            last = x;
        }

    ans = last - ans + 1;
    while(!pq.empty() && k)
        {
            ans -= pq.top();
            pq.pop(); k--;
        }

    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...