제출 #1124821

#제출 시각아이디문제언어결과실행 시간메모리
1124821awwadsStove (JOI18_stove)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h> using namespace std; bool bigger(long long a, long long b){ return a>b; } int main(){ long long N, K; cin>>N>>K; long long T[N]; for(long long i=0; i<N; i++){ cin>>T[i]; } long long differences[N-1]; for(long long i=0; i<N-1; i++){ differences[i]=T[i+1]-T[i]-1; } sort(differences,differences+N-1,bigger); long long ans=T[N-1]; for(long long 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...