Submission #1115295

#TimeUsernameProblemLanguageResultExecution timeMemory
1115295staszic_ojuzStove (JOI18_stove)C++17
100 / 100
44 ms2640 KiB
#include <iostream> #include <algorithm> typedef long long ll; using namespace std; int mal(ll a, ll b){ return a > b; } int main(){ ll n; ll k; ll suma = 0; cin >> n >> k; ll tab[n]; for(ll i = 0; i < n; i++){ cin >> tab[i]; } sort(tab, tab+n); ll roz[n-1]; for(ll i = 0; i < n-1; i++){ roz[i] = tab[i+1] - tab[i]-1; } suma = tab[n-1] - tab[0]+1; sort(roz, roz + n-1, mal); for(ll i = 0; i < min(k-1, n-1); i++){ suma -= roz[i]; } cout << suma << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...