답안 #587333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587333 2022-07-01T16:33:44 Z Fidan Stove (JOI18_stove) C++17
100 / 100
35 ms 3228 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll num=(1e9)+7;
const ll N=4*(1e5)+10;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, k, i;
	cin>>n>>k;
	vector<ll> t(n);
	
	for(i=0; i<n; i++){
		cin>>t[i];
	}
	
	sort(t.begin(), t.end());
	
	vector<ll> v;
	
	for(i=1; i<n; i++){
		v.push_back(t[i]-t[i-1]-1);
	}
	
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	
	ll l=t[n-1]+1-t[0];
	
	for(i=0; i<k-1; i++){
		l-=v[i];
	}
	
	cout<<l;
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 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 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 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 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 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 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 33 ms 3144 KB Output is correct
17 Correct 34 ms 3140 KB Output is correct
18 Correct 20 ms 3220 KB Output is correct
19 Correct 35 ms 3140 KB Output is correct
20 Correct 20 ms 3216 KB Output is correct
21 Correct 20 ms 3212 KB Output is correct
22 Correct 23 ms 3148 KB Output is correct
23 Correct 29 ms 3156 KB Output is correct
24 Correct 27 ms 3228 KB Output is correct