답안 #196894

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
196894 2020-01-17T14:05:58 Z Juney Stove (JOI18_stove) C++14
100 / 100
26 ms 2168 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5 + 5;

int N, K;
int A[MAXN], T[MAXN], ans;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K;
	for(int i=1; i<=N; i++) cin >> T[i];
	for(int i=1; i<N; i++) A[i] = T[i+1] - T[i]-1;
	sort(A+1, A+N, greater<int>());
	ans = T[N]+1 - T[1];
	for(int i=1; i<K; i++) ans -= A[i];
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 380 KB Output is correct
11 Correct 1 ms 380 KB Output is correct
12 Correct 3 ms 456 KB Output is correct
13 Correct 3 ms 396 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 380 KB Output is correct
11 Correct 1 ms 380 KB Output is correct
12 Correct 3 ms 456 KB Output is correct
13 Correct 3 ms 396 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 25 ms 2140 KB Output is correct
17 Correct 25 ms 2040 KB Output is correct
18 Correct 25 ms 2040 KB Output is correct
19 Correct 25 ms 2168 KB Output is correct
20 Correct 26 ms 2044 KB Output is correct
21 Correct 26 ms 2040 KB Output is correct
22 Correct 25 ms 2040 KB Output is correct
23 Correct 25 ms 2040 KB Output is correct
24 Correct 24 ms 2040 KB Output is correct