제출 #1197983

#제출 시각아이디문제언어결과실행 시간메모리
1197983ffeyyaae_Stove (JOI18_stove)C++20
100 / 100
15 ms1480 KiB
#include <bits/stdc++.h> using namespace std; const int N= 1e5+5; int n, k; int keep[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for( int i=0;i<n;i++ ) cin >> keep[i]; priority_queue<int> pq; for( int i=1;i<n;i++ ) pq.push( keep[i]-keep[i-1] ); int ans = keep[n-1]-keep[0]+1; for( int i=2;i<=k;i++ ) { int temp = pq.top(); pq.pop(); ans -= temp-1; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...