Submission #937488

#TimeUsernameProblemLanguageResultExecution timeMemory
937488carriewangStove (JOI18_stove)C++17
100 / 100
19 ms4828 KiB
#include <bits/stdc++.h> #define ll long long #define vi vector<int> #define pll pait<ll,ll> #define sz(x) x.size() #define all(x) x.begin(),x.end() #define F first #define S second using namespace std; priority_queue<ll> pq; ll a[1000005],n,k,ans; int main(){ ios::sync_with_stdio(0),cin.tie(0); cin >> n >> k; k--; for(int i=0;i<n;i++){ cin >> a[i]; } ans=a[n-1]-a[0]+1; for(int i=1;i<n;i++) pq.emplace(a[i]-a[i-1]-1); while(k--){ ans-=pq.top(); pq.pop(); } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...