# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1100319 | anhphant | Stove (JOI18_stove) | C++14 | 18 ms | 3540 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;
ll N, K, T[100007];
int main() {
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0); cerr.tie(0);
if (fopen("FILE.INP", "r")) {
freopen("FILE.INP", "r", stdin);
freopen("FILE.OUT", "w", stdout);
}
cin >> N >> K;
for(int i = 1; i <= N; ++i) cin >> T[i];
ll sum = T[N] + 1 - T[1];
vector<ll> v;
for(int i = 2; i <= N; ++i) {
v.push_back(T[i] - T[i - 1] - 1);
//cerr << i << " " << T[i] - T[i - 1] - 1 << '\n';
}
sort(v.begin(), v.end(), greater<ll>());
for(int i = 0; i < K - 1; ++i) {
sum -= v[i];
}
cout << sum;
}
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... |