# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
461045 |
2021-08-09T11:59:41 Z |
TeaTime |
Stove (JOI18_stove) |
C++17 |
|
28 ms |
3228 KB |
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
using namespace std;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
typedef long long ll;
typedef long double ld;
const ll SZ = 2e5 + 100, INF = 1e9 + 10, MX = 4e5 + 210;
struct qr {
ll t, l, r, i;
};
vector<qr> qs;
ll n, k;
int main() {
fastInp;
cin >> n >> k;
vector<ll> vec(n), srt;
for (auto& c : vec) cin >> c;
for (int i = 1; i < vec.size(); i++) {
srt.push_back(vec[i] - vec[i - 1] - 1);
}
sort(srt.rbegin(), srt.rend());
ll ans = vec.back() - vec[0] + 1;
for (int i = 0; i < min(ll(srt.size()), k - 1); i++) {
ans -= srt[i];
}
cout << ans;
return 0;
}
Compilation message
stove.cpp: In function 'int main()':
stove.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int i = 1; i < vec.size(); i++) {
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
272 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
272 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
272 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
22 ms |
3148 KB |
Output is correct |
17 |
Correct |
22 ms |
3140 KB |
Output is correct |
18 |
Correct |
26 ms |
3136 KB |
Output is correct |
19 |
Correct |
26 ms |
3228 KB |
Output is correct |
20 |
Correct |
28 ms |
3224 KB |
Output is correct |
21 |
Correct |
26 ms |
3148 KB |
Output is correct |
22 |
Correct |
24 ms |
3136 KB |
Output is correct |
23 |
Correct |
27 ms |
3132 KB |
Output is correct |
24 |
Correct |
22 ms |
3144 KB |
Output is correct |