Submission #1124812

#TimeUsernameProblemLanguageResultExecution timeMemory
1124812awwadsStove (JOI18_stove)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h> using namespace std; bool bigger(int a, int b){ return a>b; } int main(){ int N, K; cin>>N>>K; int T[N]; for(int i=0; i<N; i++){ cin>>T[i]; } int differences[N-1]; for(int i=0; i<N-1; i++){ differences[i]=T[i+1]-T[i]-1; } sort(differences,differences+N-1,bigger); int ans=T[N-1]; for(int i=0; i<K-1; i++){ ans-=differences[i]; } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...