Submission #1247865

#TimeUsernameProblemLanguageResultExecution timeMemory
1247865vlomaczkStove (JOI18_stove)C++20
100 / 100
13 ms2244 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> typedef long long ll; typedef long double ld; using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, k; cin >> n >> k; vector<ll> T(n); for(ll i=0; i<n; ++i) cin >> T[i]; vector<ll> diff; ll ans = T[n-1]-T[0]+1; for(int i=0; i<n-1; ++i) diff.push_back(T[i+1]-T[i]-1); sort(diff.begin(), diff.end()); for(int i=0; i<k-1; ++i) { ans -= diff.back(); diff.pop_back(); } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...