제출 #421934

#제출 시각아이디문제언어결과실행 시간메모리
421934GabpStove (JOI18_stove)C++17
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n,k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; priority_queue<int> pq; for (int i = 0; i < n - 1; i++) { pq.push(max(0, a[i + 1] - 1 - a[i])); } int total = a[n - 1] - a[0] + 1; while (!pq.empty() && k > 0) { auto i = pq.top(); pq.pop(); total -= i; k--; } cout << total; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...