# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
792448 |
2023-07-25T05:05:14 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
1 ms |
320 KB |
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
main() {
#ifdef Home
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // Home
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k, pr, cr, ans;
cin >> n >> k >> pr;
if(n == 1) {
cout << 1;
return 0;
}
vector < int > a(n);
ans = pr;
for(int i = 1; i < n; ++ i) {
cin >> cr;
a[i] = cr - pr;
pr = cr;
}
pr = ans;
ans = cr - ans + 1;
sort(a.rbegin(), a.rend());
for(int i = 0; i < k - 1; ++ i) {
ans -= a[i] - 1;
}
cout << ans - pr + 1;
}
Compilation message
stove.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |