Submission #818816

# Submission time Handle Problem Language Result Execution time Memory
818816 2023-08-10T06:49:57 Z vjudge1 Stove (JOI18_stove) C++17
100 / 100
38 ms 1616 KB
#include <bits/stdc++.h>
#define ll long long 
#define pll pair<int, int>
#define pb push_back
#define fi first
#define se second
using namespace std;
ll n, k, total, t[100010];

int main(){
	cin >> n >> k; total=n;
	vector<int>v;
	for(int i=0; i<n; i++){
		cin >> t[i];
		if(i==0) continue;
		int jeda=t[i]-t[i-1]-1;
		if(jeda>0) v.pb(jeda); 
	}
	int sz=v.size();
	if(k<sz+1){
		int kurang=sz+1-k;
		sort(v.begin(), v.end());
		for(int i=0; i<kurang; i++){
			total+=v[i];
		}
	}
	cout << total << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 34 ms 1544 KB Output is correct
17 Correct 35 ms 1580 KB Output is correct
18 Correct 34 ms 1508 KB Output is correct
19 Correct 38 ms 1540 KB Output is correct
20 Correct 34 ms 1612 KB Output is correct
21 Correct 35 ms 1476 KB Output is correct
22 Correct 34 ms 1616 KB Output is correct
23 Correct 34 ms 1500 KB Output is correct
24 Correct 35 ms 1484 KB Output is correct