제출 #94474

#제출 시각아이디문제언어결과실행 시간메모리
94474fedoseevtimofeyStove (JOI18_stove)C++14
100 / 100
22 ms1912 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, k; cin >> n >> k; int lst = -1; vector <int> dif; for (int i = 0; i < n; ++i) { int t; cin >> t; if (lst != -1) { dif.push_back(t - lst); } lst = t + 1; } int cnt = n; int ans = n; sort(dif.begin(), dif.end()); for (auto x : dif) { if (cnt > k) { --cnt; ans += x; } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...