제출 #898036

#제출 시각아이디문제언어결과실행 시간메모리
898036andrei_iorgulescuStove (JOI18_stove)C++14
100 / 100
16 ms2208 KiB
#include <bits/stdc++.h> using namespace std; int n,k,a[100005],dif[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i < n; i++) dif[i] = a[i + 1] - a[i] - 1; sort(dif + 1,dif + n); int sum = n; for (int i = 1; i <= n - k; i++) sum += dif[i]; cout << sum; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...