Submission #66721

#TimeUsernameProblemLanguageResultExecution timeMemory
66721cdemirerStove (JOI18_stove)C++17
100 / 100
93 ms5884 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vii> vvii; typedef vector<vi> vvi; typedef pair<double, double> dodo; #define pb(x) push_back(x) #define mp(x, y) make_pair(x, y) int N, K; int arr[100000]; int main(int argc, char **argv) { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> K; for (int i = 0; i < N; i++) { cin >> arr[i]; } multiset<int> MS; for (int i = 0; i < N-1; i++) { MS.insert(arr[i+1] - arr[i] - 1); } K = N-K; int ans = N; while (K--) { ans += *MS.begin(); MS.erase(MS.begin()); } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...