Submission #1092077

# Submission time Handle Problem Language Result Execution time Memory
1092077 2024-09-23T05:26:00 Z vjudge1 Stove (JOI18_stove) C++17
0 / 100
1 ms 344 KB
//Stove(Vjudge)
#include<bits/stdc++.h>

using namespace std; 

int main(){
	int n, k, cnt = 0; 
	cin >> n >> k; 
	k--;  
	int t[n + 10], dist[n + 10]; 
	for(int i = 0; i < n; i++){
		cin >> t[i]; 
	}
	t[0]++;  
	for(int i = 0; i < n - 1; i++){
		dist[i] = t[i + 1] - t[i]; 
		t[i + 1]++; 
		//cout << dist[i] << endl; 
	}
	sort(dist , dist + n);  
	for(int i = n - 2; i >= n - k - 1; i--){
		cnt += dist[i]; 
	}
	//cout << t[n - 1] << endl; 
	cout << t[n - 1] - cnt - 1 << endl; 
	//cout << cnt << endl; 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -