제출 #1298451

#제출 시각아이디문제언어결과실행 시간메모리
1298451khanhphucscratchStove (JOI18_stove)C++20
100 / 100
14 ms1484 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin>>n>>k; vector<int> t(n); for(int i = 0; i < n; i++) cin>>t[i]; int ans = t[n-1] - t[0] + 1; vector<int> a; for(int i = 1; i < n; i++) a.push_back(t[i] - t[i-1] - 1); sort(a.begin(), a.end(), greater<int>()); for(int i = 0; i < k-1; i++) ans -= a[i]; cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...