Submission #241926

# Submission time Handle Problem Language Result Execution time Memory
241926 2020-06-26T11:07:34 Z GREGOIRELC Stove (JOI18_stove) C++14
100 / 100
31 ms 2300 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_INVITE = 1e5;

int nbInvite, nbChange;
int tpsArrive[MAX_INVITE];
vector<int> diff;

int main()
{
	ios::sync_with_stdio(false);

	cin >> nbInvite >> nbChange;
	for(int iInvite = 0; iInvite < nbInvite; iInvite++)
	{
		cin >> tpsArrive[iInvite];
		if(iInvite > 0)
		{
			diff.push_back(tpsArrive[iInvite] - tpsArrive[iInvite - 1] - 1);
		}
	}
	sort(diff.begin(), diff.end());
	int result = tpsArrive[nbInvite - 1] - tpsArrive[0] + 1;
	for(int i = nbInvite - 2; i > nbInvite - 2 - nbChange + 1; i--)
	{
		result -= diff[i];
	}
	cout << result << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 31 ms 2176 KB Output is correct
17 Correct 26 ms 2176 KB Output is correct
18 Correct 29 ms 2176 KB Output is correct
19 Correct 26 ms 2300 KB Output is correct
20 Correct 28 ms 2176 KB Output is correct
21 Correct 27 ms 2300 KB Output is correct
22 Correct 27 ms 2204 KB Output is correct
23 Correct 27 ms 2176 KB Output is correct
24 Correct 27 ms 2176 KB Output is correct