제출 #277919

#제출 시각아이디문제언어결과실행 시간메모리
277919errayStove (JOI18_stove)C++17
100 / 100
29 ms2080 KiB
// author: erray #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> del; del.reserve(n - 1); int lst = 0; vector<int> a(n); for (int i = 0; i < n; ++i) { int x; cin >> x; a[i] = x; if (i > 0) { del.push_back(x - lst - 1); } lst = x; } sort(del.rbegin(), del.rend()); int e = 0; for (int i = 0; i < k - 1; ++i) { e += del[i]; } cout << a.back() + 1 - a.front() - e << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...