Submission #1115200

#TimeUsernameProblemLanguageResultExecution timeMemory
1115200staszic_ojuzStove (JOI18_stove)C++17
100 / 100
18 ms2040 KiB
#include<bits/stdc++.h> using namespace std; using i64 = int64_t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); i64 N, K; cin >> N >> K; vector<i64> bet(N - 1); vector<i64> guests(N); for (i64 i = 0; i < N; i++) { cin >> guests[i]; if (i > 0) { bet[i - 1] = guests[i] - guests[i - 1] - 1; } } sort(bet.rbegin(), bet.rend()); i64 wynik = guests[N - 1] - guests[0] + 1; for (i64 i = 1; i < K; i++) { wynik -= bet[i - 1]; } cout << wynik << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...