Submission #545425

#TimeUsernameProblemLanguageResultExecution timeMemory
545425LunaMemeStove (JOI18_stove)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef vector<pair<int, int>> vii; typedef vector<int> vi; typedef long long ll; #define PB push_back #define MP make_pair #define FOR(i, x, y) for (int i = x; i < y ; i ++) int main(){ int n, k; cin >> n >> k; int prev; vi gaps; cin >> prev; FOR(i, 0, n - 1){ int num; cin >> num; gaps.PB(num - prev - 1); prev = num; } sort(gaps.begin(), gaps.end()); ll ans = n; FOR(i, 0, k - 1){ ans += gaps[i]; } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...