답안 #278084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
278084 2020-08-21T09:59:08 Z AhmetYahya Stove (JOI18_stove) C++17
100 / 100
100 ms 2412 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long int
#define pb push_back
#define st first
#define nd second
#define lb lower_bound
 
const int N = 4000050;
 
int n, k, a, b, mak, mina;
priority_queue<int > v;
 
int32_t main(){
	cin >> n >> k;
	k--;
	cin >> b;
	mak = b;
	mina = b;
	for (int i = 1; i < n; i++){
		cin >> a;
		v.push(a-b);
		// cout << a-b << endl;
		b = a;
		mak = max(a, mak);
		mina = min(a, mina);
	}
	while(k > 0){
		k--;
		mak -= (v.top()-1);
		v.pop();
	}
	cout << mak-mina+1 << endl; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 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 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 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 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 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 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 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 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 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 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 93 ms 2288 KB Output is correct
17 Correct 87 ms 2288 KB Output is correct
18 Correct 88 ms 2288 KB Output is correct
19 Correct 88 ms 2328 KB Output is correct
20 Correct 93 ms 2292 KB Output is correct
21 Correct 98 ms 2412 KB Output is correct
22 Correct 100 ms 2288 KB Output is correct
23 Correct 99 ms 2288 KB Output is correct
24 Correct 99 ms 2308 KB Output is correct