Submission #97773

#TimeUsernameProblemLanguageResultExecution timeMemory
97773AnaiStove (JOI18_stove)C++14
100 / 100
35 ms2152 KiB
#include <bits/stdc++.h> using namespace std; vector<int> difs, v; int ant, n, k; int main() { #ifdef HOME freopen("joi_stove.in", "r", stdin); freopen("joi_stove.out", "w", stdout); #endif ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> k; v.resize(n); for (auto &i: v) cin >> i; difs.reserve(n - 1); sort(begin(v), end(v)); for (int i = 1; i < n; ++i) difs.push_back(v[i] - v[i - 1] - 1); ant = n; sort(begin(difs), end(difs)); for (int i = 0; i < n - k; ++i) ant+= difs[i]; cout << ant << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...