Submission #282798

# Submission time Handle Problem Language Result Execution time Memory
282798 2020-08-24T23:24:31 Z sofapuden Stove (JOI18_stove) C++14
100 / 100
97 ms 2936 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
	int n, k; cin >> n >> k;
	vector<ll> v(n);
	for(ll &i : v)cin >> i;
	vector<ll> dif(n-1);
	for(int i = 0; i < n-1; ++i){
		dif[i] = v[i+1]-1-v[i];
	}
	sort(dif.begin(), dif.end());
	ll ans = n;
	for(int i = 0; i < n-k; ++i){
		ans+=dif[i];
	}
	cout << ans << "\n";
	
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 128 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 128 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 128 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 92 ms 2808 KB Output is correct
17 Correct 91 ms 2844 KB Output is correct
18 Correct 91 ms 2808 KB Output is correct
19 Correct 96 ms 2808 KB Output is correct
20 Correct 93 ms 2808 KB Output is correct
21 Correct 92 ms 2804 KB Output is correct
22 Correct 92 ms 2808 KB Output is correct
23 Correct 97 ms 2808 KB Output is correct
24 Correct 94 ms 2936 KB Output is correct