# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
807002 |
2023-08-04T12:15:06 Z |
wortelworm |
Stove (JOI18_stove) |
C++17 |
|
38 ms |
2032 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, matches;
cin >> n >> matches;
vector<int> times(n);
for (int i = 0; i < n; i++)
{
cin >> times[i];
}
int total_time = times.back() + 1 - times.front();
matches--;
vector<int> diff(n - 1);
for (int i = 0; i < n - 1; i++) {
diff[i] = times[i + 1] - times[i] - 1;
}
// largest first
sort(diff.rbegin(), diff.rend());
for (int i = 0; i < n - 1; i++) {
if (matches == 0) {
break;
}
matches--;
total_time -= diff[i];
}
cout << total_time;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
35 ms |
1972 KB |
Output is correct |
17 |
Correct |
35 ms |
1948 KB |
Output is correct |
18 |
Correct |
37 ms |
1996 KB |
Output is correct |
19 |
Correct |
34 ms |
2032 KB |
Output is correct |
20 |
Correct |
34 ms |
1956 KB |
Output is correct |
21 |
Correct |
34 ms |
1912 KB |
Output is correct |
22 |
Correct |
34 ms |
1964 KB |
Output is correct |
23 |
Correct |
35 ms |
1964 KB |
Output is correct |
24 |
Correct |
38 ms |
2004 KB |
Output is correct |