Submission #548832

#TimeUsernameProblemLanguageResultExecution timeMemory
548832JokubasStove (JOI18_stove)C++14
0 / 100
1 ms340 KiB
#include <iostream> #include <bits/stdc++.h> #define pb push_back using namespace std; int main() { int N, K; cin>>N>>K; int kada[N]; for(int i = 0; i<N; i++) { cin>>kada[i]; } sort(kada, kada+N); priority_queue<int> q; int praeitas = kada[0]; for(int i = 1; i<N; i++) { q.push(kada[i] - praeitas - 1); praeitas = kada[i]; } int ats = kada[N-1]; for(int i = 0; i<K-1; i++) { ats-=q.top(); q.pop(); } cout<<ats; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...