Submission #907048

#TimeUsernameProblemLanguageResultExecution timeMemory
907048The_SamuraiStove (JOI18_stove)C++17
100 / 100
17 ms2524 KiB
// I stand with PALESTINE //#pragma GCC optimize("Ofast,O3") //#pragma GCC target("avx,avx2") #include "bits/stdc++.h" using namespace std; using ll = long long; const ll inf = 1e18; void solve() { int n, k; cin >> n >> k; vector<int> t(n), d; for (int &x: t) cin >> x; for (int i = 1; i < n; i++) d.emplace_back(t[i] - t[i - 1]); int ans = t.back() + 1 - t[0]; sort(d.rbegin(), d.rend()); k--; for (int i = 0; i < k; i++) ans -= d[i] - 1; cout << ans; } int main() { cin.tie(0)->sync_with_stdio(false); #ifdef sunnatov freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int q = 1; // cin >> q; while (q--) { solve(); cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...