# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
206747 |
2020-03-05T04:06:44 Z |
pavement |
Stove (JOI18_stove) |
C++17 |
|
32 ms |
5500 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N, K, C, T[100005];
vector<pair<int, int> > V;
vector<int> Y;
main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N >> K;
for (int i = 1; i <= N; i++) {
cin >> T[i];
if (i != 1 && T[i - 1] + 1 == T[i]) {
auto ii = V.back();
V.pop_back();
V.emplace_back(ii.first, T[i] + 1);
} else V.emplace_back(T[i], T[i] + 1);
}
for (auto i : V)
C += i.second - i.first;
for (int i = 0; i < V.size() - 1; i++)
Y.push_back(V[i + 1].first - V[i].second);
sort(Y.begin(), Y.end());
for (int i = 1; i <= max((int)V.size() - K, 0ll); i++) C += Y[i - 1];
cout << C << '\n';
}
Compilation message
stove.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
stove.cpp: In function 'int main()':
stove.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < V.size() - 1; i++)
~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
504 KB |
Output is correct |
11 |
Correct |
5 ms |
504 KB |
Output is correct |
12 |
Correct |
5 ms |
504 KB |
Output is correct |
13 |
Correct |
5 ms |
504 KB |
Output is correct |
14 |
Correct |
6 ms |
504 KB |
Output is correct |
15 |
Correct |
6 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
504 KB |
Output is correct |
11 |
Correct |
5 ms |
504 KB |
Output is correct |
12 |
Correct |
5 ms |
504 KB |
Output is correct |
13 |
Correct |
5 ms |
504 KB |
Output is correct |
14 |
Correct |
6 ms |
504 KB |
Output is correct |
15 |
Correct |
6 ms |
504 KB |
Output is correct |
16 |
Correct |
32 ms |
5480 KB |
Output is correct |
17 |
Correct |
32 ms |
5500 KB |
Output is correct |
18 |
Correct |
32 ms |
5480 KB |
Output is correct |
19 |
Correct |
32 ms |
5480 KB |
Output is correct |
20 |
Correct |
31 ms |
5480 KB |
Output is correct |
21 |
Correct |
30 ms |
5480 KB |
Output is correct |
22 |
Correct |
30 ms |
5484 KB |
Output is correct |
23 |
Correct |
31 ms |
5480 KB |
Output is correct |
24 |
Correct |
32 ms |
5484 KB |
Output is correct |