이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int t[MAXN], timeDif[MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k, i;
    cin >> n >> k;
    cin >> t[0];
    for(i = 1; i < n; i++){
        cin >> t[i];
        timeDif[i] = t[i] - t[i - 1]; // How much time the stove runs
    }
    sort(timeDif + 1, timeDif + n); // Sort to get the minimum time
    int ans = n;
    for(i = 1; i <= n - k; ++i){ // He can turn it on at most K times, so we go until N - K
        ans += --timeDif[i];
    }
    cout << ans;
    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... |