Submission #170620

#TimeUsernameProblemLanguageResultExecution timeMemory
170620mdn2002Stove (JOI18_stove)C++14
100 / 100
61 ms6052 KiB
#include<bits/stdc++.h> using namespace std; const long long mod=998244353; long long n,k; multiset<long long>ms; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(".in","r",stdin); //freopen(".out","w",stdout); cin>>n>>k; int a,b; cin>>b; for(int i=0;i<n-1;i++) { cin>>a; ms.insert(a-b); b=a; } long long ans=n; for(int i=0;i<n-k;i++) { ans+=*ms.begin()-1; ms.erase(ms.begin()); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...