Submission #1088489

# Submission time Handle Problem Language Result Execution time Memory
1088489 2024-09-14T13:58:29 Z Staheos Stove (JOI18_stove) C++14
0 / 100
0 ms 344 KB
#include <iostream>
#include <queue>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	int s = n;

	int* t = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> t[i];
	}

	auto q = priority_queue<int>();
	for (int i = 1; i < n; i++)
	{
		if (t[i - 1] != t[i] - 1)
		{
			q.push(t[i] - t[i - 1] - 1);
		}
		else
		{
			s--;
		}
	}

	k--;
	while (k > 0 && !q.empty())
	{
		q.pop();
		k--;
	}

	while (!q.empty())
	{
		s += q.top();
		q.pop();
	}

	cout << s << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -