Submission #1247864

#TimeUsernameProblemLanguageResultExecution timeMemory
1247864vlomaczkStove (JOI18_stove)C++20
0 / 100
0 ms328 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+1, -1); for(ll i=1; i<=n; ++i) cin >> T[i]; vector<ll> diff; ll ans = T[n]-T[1]+1; for(int i=0; i<n; ++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...