답안 #164120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164120 2019-11-17T13:51:44 Z cfalas Stove (JOI18_stove) C++14
100 / 100
87 ms 1908 KB
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define ll long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

int main(){
	int n, k;
	cin>>n>>k;
	int pr, c;
	cin>>pr;
	vi tot;
	for(int i=0;i<n-1;i++){
		cin>>c;
		//cout<<c - pr<<endl;
		tot.push_back(c - pr - 1);
		pr = c;
	}
	sort(tot.begin(), tot.end());
	int ans = n;
	for(int i=0;i<(n-k);i++){
		ans+=tot[i];
	}
	cout<<ans<<endl;


}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 368 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 368 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 84 ms 1812 KB Output is correct
17 Correct 85 ms 1780 KB Output is correct
18 Correct 83 ms 1780 KB Output is correct
19 Correct 86 ms 1908 KB Output is correct
20 Correct 85 ms 1880 KB Output is correct
21 Correct 84 ms 1780 KB Output is correct
22 Correct 85 ms 1804 KB Output is correct
23 Correct 84 ms 1780 KB Output is correct
24 Correct 87 ms 1780 KB Output is correct