제출 #763887

#제출 시각아이디문제언어결과실행 시간메모리
763887ind1vStove (JOI18_stove)C++11
100 / 100
17 ms2160 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, k; int t[N]; vector<int> gaps; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> t[i]; if (i > 1) { gaps.emplace_back(t[i] - t[i - 1] - 1); } } int ans = t[n] - t[1] + 1; sort(gaps.begin(), gaps.end()); --k; while (k--) { ans -= gaps.back(); gaps.pop_back(); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...