| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1355772 | truongthaiduonglaptrinh | Stove (JOI18_stove) | C++20 | 16 ms | 1212 KiB |
// duonglaptrinh
# include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
bool find_Max(int &ans, int x) {
// cout<<x<<"\n";
if(x == -1) {
return 0;
}
ans = min(ans, x);
return 1;
}
int n, k;
int a[N], b[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if(fopen("nhap.inp", "r")) {
freopen("nhap.inp", "r", stdin);
freopen("nhap.out", "w", stdout);
}
cin>>n>>k;
for(int i = 1; i <= n; i++) {
cin>>a[i];
}
sort(a + 1, a + 1 + n);
for(int i = 1; i < n; i++) {
b[i] = (a[i + 1] - a[i] - 1);
}
sort(b + 1, b + n, greater<>());
int ans = a[n] - a[1] + 1;
for(int i = 1; i <= min(n - 1, k - 1); i++) {
ans -= b[i];
}
cout<<ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
