Submission #948725

# Submission time Handle Problem Language Result Execution time Memory
948725 2024-03-18T12:39:43 Z phoenix0423 Stove (JOI18_stove) C++17
100 / 100
19 ms 2664 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 2e5 + 5;

signed main(void){
	fastio;
	int n, k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin>>a[i];
	int ans = n;
	vector<int> val;
	for(int i = 1; i < n; i++) val.pb(a[i] - a[i - 1] - 1);
	sort(val.begin(), val.end());
	int use = n - k;
	for(int i = 0; i < use; i++) ans += val[i];
	cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 1 ms 532 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 1 ms 532 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 15 ms 2664 KB Output is correct
17 Correct 15 ms 2272 KB Output is correct
18 Correct 19 ms 2464 KB Output is correct
19 Correct 15 ms 2360 KB Output is correct
20 Correct 14 ms 2272 KB Output is correct
21 Correct 16 ms 2388 KB Output is correct
22 Correct 16 ms 2400 KB Output is correct
23 Correct 14 ms 2272 KB Output is correct
24 Correct 17 ms 2392 KB Output is correct