제출 #1285965

#제출 시각아이디문제언어결과실행 시간메모리
1285965harryleeeStove (JOI18_stove)C++20
100 / 100
29 ms5508 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 1e5; multiset<long long> s; int n, k, a[maxn + 1]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; a[0] = -1e9; for (int i = 1; i <= n; ++i){ cin >> a[i]; s.insert(a[i] - a[i - 1]); } long long res = k; n -= k; while(n--){ res += *s.begin(); s.erase(s.begin()); } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...