# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
587109 |
2022-07-01T10:29:59 Z |
proma |
Stove (JOI18_stove) |
C++17 |
|
1 ms |
328 KB |
#include <bits/stdc++.h>
#define int long long
#define see(x) cout<<#x<<"="<<x<<"\n";
#define endl "\n"
using namespace std;
const int N = 1e5+5;
int n, k, t[N];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
*/
cin >> n >> k;
vector <pair <int, int>> stop;
for (int i = 0; i < n; i ++) {
cin >> t[i];
}
for (int i = 0; i < n; i ++) {
if (i + 1 < n) {
stop.push_back({t[i+1] - t[i], t[i]+1});
}
}
sort(stop.rbegin(), stop.rend());
vector <int> v;
for (int i = 0; i < k - 1; i ++) {
v.push_back(stop[i].second);
}
v.push_back(t[n-1] + 1);
sort(v.begin(), v.end());
int flag = 0, res = 0, pos = 0;
for (int i = 0; i < n; i ++) {
if (v[pos] < t[i]) {
pos ++;
flag = 0;
}
if (!flag) {
res += v[pos] - t[i];
flag = 1;
}
}
cout << res << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |