# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1101083 | akzytr | Stove (JOI18_stove) | C++17 | 41 ms | 2268 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n,q;
cin >>n >>q;
int x = 0;
vector<int> t(n);
for(int i = 0; i < n; i++){
cin >> t[i];
}
int ans = t[n-1] - t[0]+1;
vector<int> gaps;
for(int i = 1; i < n; i++){
gaps.push_back(t[i] - t[i-1]-1);
}
sort(gaps.rbegin(), gaps.rend());
for(int i = 0; i < q-1; i++){
ans -= gaps[i];
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |