제출 #1088466

#제출 시각아이디문제언어결과실행 시간메모리
1088466RoupiqStove (JOI18_stove)C++17
100 / 100
18 ms2004 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define len(x) (int)x.size() #define x first #define y second using pii = pair<int, int>; template <typename T1, typename T2> ostream &operator<<(ostream &_o, pair<T1, T2> _a) { _o << _a.x << " " << _a.y; return _o; } int n, k; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> k; priority_queue<int> dif; int last; cin >> last; last++; for (int i = 1; i < n; i++) { int a, b; cin >> a; b = a + 1; dif.push(-(a - last)); last = b; } int res = 0; while(len(dif) > k - 1) { res += -dif.top(); dif.pop(); } cout << res + n << "\n"; } /* 3 2 1 3 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...