이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
void solve() {
int n, k;
cin >> n >> k;
int ans = n;
int prev = 0;
vector<int> aboba;
for (int i = 0; i < n; i++) {
int ti;
cin >> ti;
if (prev != 0)
aboba.push_back(ti - prev - 1);
prev = ti;
}
sort(aboba.begin(), aboba.end());
for (int i = 0; i < n - k; i++)
ans += aboba[i];
cout << ans;
}
signed main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |