제출 #219142

#제출 시각아이디문제언어결과실행 시간메모리
219142shart23Stove (JOI18_stove)C++14
100 / 100
28 ms3324 KiB
#include <bits/stdc++.h> #define endl "\n" #define int long long #define fir first #define sec second using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, k; cin >> n >> k; vector<int> t(n); for (auto &x : t) { cin >> x; } int res = t.back() - t[0] + 1; vector<int> nov; for (int i = 0; i < n - 1; i++) { nov.push_back(t[i + 1] - t[i] - 1); } sort(nov.begin(), nov.end()); reverse(nov.begin(), nov.end()); for (int i = 0; i < k - 1; i++) { res -= nov[i]; } cout << res << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...