이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
#ifdef palilo
freopen("in", "r", stdin);
freopen("out", "w", stdout);
#endif
int n, k;
cin >> n >> k;
vector<int> a(n - 1);
{
int prv, cur;
cin >> prv;
for (auto& x : a) {
cin >> cur;
x = cur - prv;
prv = cur;
}
}
sort(a.begin(), a.end());
const auto res = accumulate(a.begin(), a.end() - (k - 1), 0);
cout << res + k;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |