Submission #1257426

#TimeUsernameProblemLanguageResultExecution timeMemory
1257426dhananStove (JOI18_stove)C++20
100 / 100
29 ms1968 KiB
#include <bits/stdc++.h> using namespace std; using ayo = int; using llll = long long; ayo main(){ llll N, K; cin >> N >> K; vector <llll> tamu(N); for(int i = 0; i < N; i++){ cin >> tamu[i]; } if(K >= N){ cout << N; return 0; } vector<llll> yaps; for(int i = 0; i < N; i++){ yaps.reserve(N - 1); } for(int i = 0; i < N - 1; i++){ llll awasadasule = tamu[i + 1] - tamu[i] - 1; yaps.push_back(awasadasule); } sort(yaps.begin(), yaps.end()); llll gabungkanOK = N - K; // menggabungkan llll neraka = 0; // tambahan || ekstra for(int i = 0; i < gabungkanOK; i++){ neraka += yaps[i]; } llll jawabanpleasewoi = N + neraka; cout << jawabanpleasewoi; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...