# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1049761 | vjudge1 | Stove (JOI18_stove) | C++17 | 41 ms | 1480 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 60 * 10000
void solve() {
int n,k;
cin >> n >> k;
vector <int> a(n);
vector <int> b;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n - 1; i++) {
b.push_back(a[i+1] - a[i]);
} sort(b.begin(),b.end());
if (k == 1) {
cout << a[n - 1] - a[0] + 1;
return;
} else if (n == k) {
cout << n ;
return;
}
int ans1 = a[n - 1] -a[0] + 1;
int ans = 0;
for (int i = 0; i < n - 1; i++) {
ans += b[i] + 1;
k--;
if (n - (i + 1)*2 <= k) {
ans += k;
break;
}
} cout << ans;
}
int main()
{
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |