제출 #531240

#제출 시각아이디문제언어결과실행 시간메모리
531240Halym2007Stove (JOI18_stove)C++11
100 / 100
19 ms2280 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define cont continue; #define sz size() #define pb push_back using namespace std; typedef long long ll; const int N = 100005; void solve(); int n, k, a[N], jogap; vector <int> v; int main() { ios::sync_with_stdio(false); cin.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); cin >> n >> k; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i < n; ++i) { v.pb (a[i + 1] - a[i] - 1); } sort (v.begin(), v.end()); for (int i = 0; i < n-k; ++i) { jogap += v[i]; } cout << n + jogap << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...