# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
66764 |
2018-08-12T09:23:12 Z |
quoriess |
Stove (JOI18_stove) |
C++14 |
|
3 ms |
584 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pii;
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]=marked[a+1]=true;
}
k--;
sort(times.begin(),times.end());
int len=times.size();
priority_queue<lli> maxBosluklar;
for (int i = 1; i < len; i++)
{
maxBosluklar.push(times[i]-times[i-1]);
}
lli sz=times[len-1]-times[0];
while(k>0 && !maxBosluklar.empty() && maxBosluklar.top()!=0){
lli t=maxBosluklar.top();
sz-=t;
maxBosluklar.pop();
k--;
}
cout << sz<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
528 KB |
Output is correct |
4 |
Correct |
3 ms |
528 KB |
Output is correct |
5 |
Incorrect |
2 ms |
584 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
528 KB |
Output is correct |
4 |
Correct |
3 ms |
528 KB |
Output is correct |
5 |
Incorrect |
2 ms |
584 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
528 KB |
Output is correct |
4 |
Correct |
3 ms |
528 KB |
Output is correct |
5 |
Incorrect |
2 ms |
584 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |