Submission #156961

#TimeUsernameProblemLanguageResultExecution timeMemory
156961a_playerStove (JOI18_stove)C++14
100 / 100
88 ms2936 KiB
#include <bits/stdc++.h> #define f first #define s second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; ll diff[100001]; ll v[100001]; int N,K; ll s=0; int main(){ cin>>N>>K; for(int i=0;i<N;i++)cin>>v[i]; for(int i=0;i<N-1;i++){ diff[i]=v[i+1]-v[i]; s+=diff[i]; } sort(diff,diff+(N-1),greater<ll>()); for(int i=0;i<K-1;i++)s-=diff[i]-1; cout<<s+1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...