제출 #729346

#제출 시각아이디문제언어결과실행 시간메모리
729346PringStove (JOI18_stove)C++14
100 / 100
20 ms2864 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pii; const int MXN = 200005; int a[MXN], d[MXN], n, k, ans; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n; i++) d[i - 1] = a[i] - a[i - 1] - 1; sort(d, d + n - 1); ans = n; for (int i = 0; i < (n - k); i++) ans += d[i]; cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...