Submission #1246279

#TimeUsernameProblemLanguageResultExecution timeMemory
1246279luka_zecevicStove (JOI18_stove)C++20
0 / 100
0 ms324 KiB
#include "bits/stdc++.h" #define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define ff first #define ss second #define ll long long using namespace std; int main() { FAST; int n, k; cin >> n >> k; vector < int > v(n); for(int i = 0; i < n; i++) cin >> v[i]; vector < int > p; for(int i = 1; i < n; i++) p.push_back(v[i] - v[i - 1] - 1); sort(begin(p), end(p), greater < int > ()); int ans = v[n - 1]; for(int i = 0; i < k - 1; i++) ans -= p[i]; cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...