제출 #936696

#제출 시각아이디문제언어결과실행 시간메모리
9366964QT0RStove (JOI18_stove)C++17
100 / 100
19 ms2404 KiB
#include <bits/stdc++.h> using namespace std; priority_queue<int> pq; int wej[100003]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,k,st; cin >> n >> k; for (int i = 1; i<=n; i++){ cin >> wej[i]; } st=wej[n]-wej[1]+1; for (int i = 2; i<=n; i++){ pq.push(wej[i]-wej[i-1]-1); } for (int i = 1; (i<=k-1) && pq.size(); i++){ st-=pq.top(); pq.pop(); } cout << st << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...