Submission #1124815

#TimeUsernameProblemLanguageResultExecution timeMemory
1124815vs358Stove (JOI18_stove)C++20
100 / 100
16 ms2356 KiB
#include <bits/stdc++.h> #define int long long #define ull unsigned long long #define ld long double #define INFF 300000 #define INF (LLONG_MAX - 100) #define mp make_pair #define DEBUG(x) cout << "DEBUG: " << x << endl; #define drugs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) using namespace std; typedef pair<int, int> pi; typedef pair<int, pi> ipi; typedef pair<pi, int> pii; signed main(){ drugs; int n, k; cin >> n >> k; int ans = n; vector<int> arr(n); vector<int> diff; for(int i = 0; i < n; i++){ cin >> arr[i]; if(i != 0) diff.push_back(arr[i] - arr[i-1]); } sort(diff.begin(), diff.end()); for(int i = 0; i < n-k; i++){ ans += diff[i] - 1; } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...