# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
66774 |
2018-08-12T09:56:44 Z |
quoriess |
Stove (JOI18_stove) |
C++14 |
|
279 ms |
17788 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pii;
typedef pair<lli,pii> data;
int main(){
int n,k;
cin>>n>>k;
vector<lli> times;
map<lli,bool> marked;
for (int i = 0; i < n; i++)
{
int a;
cin>>a;
if(marked.find(a)==marked.end()){
times.push_back(a);
}
if(marked.find(a+1)==marked.end()){
times.push_back(a+1);
}
marked[a+1]=true;
marked[a]=false;
}
k--;
sort(times.begin(),times.end());
int len=times.size();
priority_queue<lli> maxBosluklar;
for (int i = 1; i < len; i++)
{
if(marked[times[i-1]]){
maxBosluklar.push(times[i]-times[i-1]);
}
}
lli sz=times[len-1]-times[0];
while(k>0 && !maxBosluklar.empty()){
lli t=maxBosluklar.top();
maxBosluklar.pop();
sz-=t;
k--;
}
cout << sz<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
2 ms |
484 KB |
Output is correct |
5 |
Correct |
2 ms |
484 KB |
Output is correct |
6 |
Correct |
3 ms |
516 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
3 ms |
516 KB |
Output is correct |
9 |
Correct |
2 ms |
516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
2 ms |
484 KB |
Output is correct |
5 |
Correct |
2 ms |
484 KB |
Output is correct |
6 |
Correct |
3 ms |
516 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
3 ms |
516 KB |
Output is correct |
9 |
Correct |
2 ms |
516 KB |
Output is correct |
10 |
Correct |
6 ms |
1028 KB |
Output is correct |
11 |
Correct |
6 ms |
1072 KB |
Output is correct |
12 |
Correct |
7 ms |
1072 KB |
Output is correct |
13 |
Correct |
8 ms |
1072 KB |
Output is correct |
14 |
Correct |
7 ms |
1072 KB |
Output is correct |
15 |
Correct |
8 ms |
1096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
2 ms |
484 KB |
Output is correct |
5 |
Correct |
2 ms |
484 KB |
Output is correct |
6 |
Correct |
3 ms |
516 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
3 ms |
516 KB |
Output is correct |
9 |
Correct |
2 ms |
516 KB |
Output is correct |
10 |
Correct |
6 ms |
1028 KB |
Output is correct |
11 |
Correct |
6 ms |
1072 KB |
Output is correct |
12 |
Correct |
7 ms |
1072 KB |
Output is correct |
13 |
Correct |
8 ms |
1072 KB |
Output is correct |
14 |
Correct |
7 ms |
1072 KB |
Output is correct |
15 |
Correct |
8 ms |
1096 KB |
Output is correct |
16 |
Correct |
229 ms |
17636 KB |
Output is correct |
17 |
Correct |
223 ms |
17788 KB |
Output is correct |
18 |
Correct |
232 ms |
17788 KB |
Output is correct |
19 |
Correct |
222 ms |
17788 KB |
Output is correct |
20 |
Correct |
242 ms |
17788 KB |
Output is correct |
21 |
Correct |
239 ms |
17788 KB |
Output is correct |
22 |
Correct |
243 ms |
17788 KB |
Output is correct |
23 |
Correct |
252 ms |
17788 KB |
Output is correct |
24 |
Correct |
279 ms |
17788 KB |
Output is correct |