Submission #1231663

#TimeUsernameProblemLanguageResultExecution timeMemory
1231663antromancapStove (JOI18_stove)C++20
100 / 100
12 ms1096 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; int n, k, a[N], b[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i < n; i++) b[i] = a[i + 1] - a[i] - 1; sort(b + 1, b + n, greater<int>()); int res = a[n] + 1 - a[1]; for (int i = 1; i < k; i++) res -= b[i]; cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...