답안 #299617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
299617 2020-09-15T10:48:31 Z Ronin13 Stove (JOI18_stove) C++14
100 / 100
106 ms 2168 KB
#include<bits/stdc++.h>
#define ll long long
#define  f first
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define mp make_pair
#define  s second

using namespace std;



int main(){

		int n;cin>>n;
		int k;cin>>k;
		int a[n+1];
		for(int i=1;i<=n;i++)cin>>a[i];
		sort(a+1,a+1+n);
		int d[n];
		for(int i=1;i<n;i++){
			d[i]=a[i+1]-a[i]-1;
		}
		sort(d+1,d+n);
		int ans=n;
		for(int i=1;i<=n-k;i++)ans+=d[i];
		cout<<ans;
		//problem locked!
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 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 512 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 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 512 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 94 ms 2040 KB Output is correct
17 Correct 106 ms 2044 KB Output is correct
18 Correct 95 ms 2040 KB Output is correct
19 Correct 96 ms 2044 KB Output is correct
20 Correct 94 ms 2168 KB Output is correct
21 Correct 93 ms 2040 KB Output is correct
22 Correct 93 ms 2040 KB Output is correct
23 Correct 95 ms 2168 KB Output is correct
24 Correct 94 ms 2040 KB Output is correct