Submission #1108107

#TimeUsernameProblemLanguageResultExecution timeMemory
1108107rixiepixieStove (JOI18_stove)C++17
100 / 100
17 ms2508 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { cin.tie(0); ios_base::sync_with_stdio(false); /// int n, k; cin >> n >> k; vector<int> t(n); for (int i = 0; i < n; i++) cin >> t[i]; vector<int> gaps; for (int i = 0; i < n - 1; i++) { int gap = t[i + 1] - (t[i] + 1); gaps.push_back(gap); } sort(gaps.begin(), gaps.end()); int total_time = n; for (int i = 0; i < n - k; i++) { total_time += gaps[i]; } cout << total_time << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...