Submission #1091256

#TimeUsernameProblemLanguageResultExecution timeMemory
1091256___Stove (JOI18_stove)C++17
100 / 100
15 ms3292 KiB
#include <bits/stdc++.h> #define int long long int #define ff first #define ss second #define FT ios_base::sync_with_stdio(false);cin.tie(0); using namespace std; vector <int> diff; const int maxn = 1e5 + 10; int t[maxn]; signed main() { FT; int n , k; cin >> n >> k; for (int i = 1 ; i <= n ; i++) { cin >> t[i]; } for (int i = 2 ; i <= n ; i++) { diff.push_back(t[i] - (t[i - 1] + 1)); } sort (diff.begin() , diff.end()); int ans = n; for (int i = 0 ; i < n - k ; i++) { ans += diff[i]; } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...