이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define int long long
#define N 500002
#define M 1000000007
#define pii pair<int, int>
#define piii pair<pii, int>
using namespace std;
int n, k, i, ans, a[N];
vector<int> v;
main()
{
std::ios::sync_with_stdio(0);
cin.tie();
cin >> n >> k;
for(i = 0; i < n; i++)
cin >> a[i];
ans = n;
sort(a, a + n);
for(i = 1; i < n; i++)
v.pb(a[i] - a[i - 1] - 1);
sort(v.begin(), v.end());
for(i = 0; i < n - k; i++)
ans += v[i];
cout << ans << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
stove.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main()
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |