# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
206392 |
2020-03-03T08:06:39 Z |
stefdasca |
Stove (JOI18_stove) |
C++14 |
|
67 ms |
6904 KB |
#include<bits/stdc++.h>
using namespace std;
int n, k, x, v[100002], beg[100002];
set<pair<int, int> >s;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
x = n;
for(int i = 1; i <= n; ++i)
cin >> v[i];
for(int i = 1; i <= n; ++i)
{
beg[i] = 1;
if(i < n)
s.insert({v[i+1] - v[i], i+1});
}
while(x > k)
{
pair<int, int> xx = *s.begin();
s.erase(xx);
beg[xx.second] = 0;
--x;
}
int cost = 0;
int lst = 0;
beg[n+1] = 1;
for(int i = 1; i <= n+1; ++i)
{
if(beg[i] == 1)
{
if(lst != 0)
{
cost = cost + v[i-1] - lst + 1;
lst = v[i];
}
else
lst = v[i];
}
}
cout << cost;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 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 |
5 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 |
6 ms |
504 KB |
Output is correct |
12 |
Correct |
6 ms |
504 KB |
Output is correct |
13 |
Correct |
6 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 |
5 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 |
6 ms |
504 KB |
Output is correct |
12 |
Correct |
6 ms |
504 KB |
Output is correct |
13 |
Correct |
6 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 |
61 ms |
6776 KB |
Output is correct |
17 |
Correct |
67 ms |
6904 KB |
Output is correct |
18 |
Correct |
67 ms |
6776 KB |
Output is correct |
19 |
Correct |
59 ms |
6776 KB |
Output is correct |
20 |
Correct |
63 ms |
6824 KB |
Output is correct |
21 |
Correct |
56 ms |
6904 KB |
Output is correct |
22 |
Correct |
54 ms |
6776 KB |
Output is correct |
23 |
Correct |
55 ms |
6780 KB |
Output is correct |
24 |
Correct |
54 ms |
6776 KB |
Output is correct |