Submission #1135102

#TimeUsernameProblemLanguageResultExecution timeMemory
1135102nikatamlianiStove (JOI18_stove)C++20
100 / 100
13 ms2244 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int N, K; cin >> N >> K; vector<int> t(N); for (int i = 0; i < N; ++i) { cin >> t[i]; } vector<int> differences; for (int i = 1; i < N; ++i) { differences.push_back(t[i] - t[i - 1]); } int sum = t[N - 1] - t[0] + 1; sort(differences.rbegin(), differences.rend()); for (int i = 0; i < K - 1; ++i) { sum -= differences[i] - 1; } cout << sum << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...