Submission #651065

# Submission time Handle Problem Language Result Execution time Memory
651065 2022-10-16T21:05:40 Z teesla Stove (JOI18_stove) C++14
100 / 100
55 ms 1800 KB
#include <bits/stdc++.h>
using namespace std;

bool cmp(int a,int b){
	return a>b;
}

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

	vector<int>v;

	int atual;
	cin >> atual;
	int primeiro=atual;
	int ultimo;

	for(int i=1; i<n; i++){
		int a;
		cin >> a;
		v.push_back(a-atual-1);
		atual=a;
	}
	ultimo=atual;

	sort(v.begin(),v.end(),cmp);

	int res=ultimo-primeiro+1;

	for(int i=0; i<k-1; i++){
		res-=v[i];
	}

	cout << res<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 312 KB Output is correct
12 Correct 2 ms 308 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 312 KB Output is correct
12 Correct 2 ms 308 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
16 Correct 48 ms 1800 KB Output is correct
17 Correct 47 ms 1736 KB Output is correct
18 Correct 48 ms 1736 KB Output is correct
19 Correct 45 ms 1784 KB Output is correct
20 Correct 48 ms 1712 KB Output is correct
21 Correct 45 ms 1736 KB Output is correct
22 Correct 45 ms 1772 KB Output is correct
23 Correct 47 ms 1756 KB Output is correct
24 Correct 55 ms 1792 KB Output is correct