Submission #1010304

#TimeUsernameProblemLanguageResultExecution timeMemory
1010304THXuanStove (JOI18_stove)C++14
100 / 100
16 ms2268 KiB
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <set> #include <map> #define INF 1e9 using namespace std; typedef long long ll; void solve() { int n, k; cin >> n >> k; vector<ll>v(n), a; for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 1; i < n; i++) a.push_back(v[i] - (v[i - 1] + 1)); sort(a.rbegin(), a.rend()); ll ans = (v[n - 1] - v[0]) + 1; for (int i = 0; i < k - 1; i++) ans -= a[i]; cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1;// cin>>t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...