제출 #1316977

#제출 시각아이디문제언어결과실행 시간메모리
1316977djsksbrbfStove (JOI18_stove)C++20
100 / 100
41 ms2340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int n, k; cin >> n >> k; int a[100005]; for(int i = 1 ; i <= n ; i++)cin >> a[i]; int ans = a[n] - a[1] + 1; priority_queue <int> pq; for(int i = 2 ; i <= n ; i++)pq.push(a[i] - (a[i - 1] + 1)); int t = k - 1; while(t-- && pq.size()){ ans -= pq.top(); pq.pop(); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...