제출 #1323440

#제출 시각아이디문제언어결과실행 시간메모리
1323440python_devopoverStove (JOI18_stove)C++20
100 / 100
13 ms1996 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i]; if(k >= n){ cout << n << endl; return 0; } vector<int> pf(n); for(int i = 0; i + 1 < n; i++){ pf[i] = a[i + 1] - (a[i] + 1); } sort(all(pf)); int ans = n; for(int i = 0; i < n - k + 1; i++) ans += pf[i]; cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...