Submission #66771

# Submission time Handle Problem Language Result Execution time Memory
66771 2018-08-12T09:52:56 Z quoriess Stove (JOI18_stove) C++14
0 / 100
3 ms 476 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){
		lli t=maxBosluklar.top();
		maxBosluklar.pop();
		sz-=t;
		k--;
	}
	cout << sz<<"\n";
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Incorrect 2 ms 476 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Incorrect 2 ms 476 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Incorrect 2 ms 476 KB Output isn't correct
6 Halted 0 ms 0 KB -