Submission #335369

#TimeUsernameProblemLanguageResultExecution timeMemory
335369AQTStove (JOI18_stove)C++17
100 / 100
27 ms2048 KiB
#include <bits/stdc++.h> using namespace std; int N, K; int arr[100005]; int dif[100005]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K; for(int i = 1; i<=N; i++){ cin >> arr[i]; dif[i-1] = arr[i] - arr[i-1]; } sort(dif+1, dif+N); K = N - K; int ans = 0; for(int i = 1; i<=K; i++){ ans += dif[i]; } cout << ans+ N - K << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...