답안 #734059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734059 2023-05-01T15:27:19 Z haydendoo Stove (JOI18_stove) C++17
100 / 100
25 ms 3284 KB
#include <bits/stdc++.h>  //needa retype template incase bret reynold yeah bruh moment ill me
using namespace std;

#define int long long 
typedef pair<int,int>pii;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;

	int arr[n+5];

	for(int x=1;x<=n;x++){
		cin >> arr[x];
	}

	priority_queue<int,vector<int>,greater<int>>pq;
	for(int x=2;x<=n;x++){
		pq.push(arr[x]-arr[x-1]-1);
	}

	int counter=n;

    for(int bruh=0; bruh<n-k; ++bruh) {
        auto cur=pq.top();
        counter+=cur;
        pq.pop();
	}
	cout << counter;
}
/*
10 5
1
2
5
6
8
11
13
15
16
20
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 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 212 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 212 KB Output is correct
4 Correct 1 ms 320 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 212 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 336 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 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 368 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 212 KB Output is correct
4 Correct 1 ms 320 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 212 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 336 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 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 368 KB Output is correct
16 Correct 23 ms 3104 KB Output is correct
17 Correct 24 ms 3284 KB Output is correct
18 Correct 24 ms 3132 KB Output is correct
19 Correct 25 ms 3212 KB Output is correct
20 Correct 19 ms 3124 KB Output is correct
21 Correct 14 ms 3124 KB Output is correct
22 Correct 16 ms 3124 KB Output is correct
23 Correct 13 ms 3136 KB Output is correct
24 Correct 13 ms 3108 KB Output is correct