답안 #651139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
651139 2022-10-17T11:00:23 Z PagodePaiva Stove (JOI18_stove) C++14
100 / 100
27 ms 3244 KB
#include<bits/stdc++.h>
#define int long long 
#define ms(v) memset(v, -1, sizeof v)
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define INF 1e15
#define mp make_pair
#define itn int
#define N 100010

using namespace std;

int n, k;
int v[N];

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    
    for(int i = 1;i <= n;i++){
        cin >> v[i];
    }

    k--;
    int res = v[n] - v[1] + 1;

    priority_queue <int> pq;

    for(int i = 2;i <= n;i++){
        pq.push(v[i] - v[i-1] - 1);
    }

    while(k != 0){
        int x = pq.top();
        pq.pop();
        res -= x;
        k--;
    }

    cout << res << "\n"; 

    return 0;   
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 328 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 0 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 328 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 472 KB Output is correct
11 Correct 1 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 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 328 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 472 KB Output is correct
11 Correct 1 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 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 14 ms 3176 KB Output is correct
17 Correct 15 ms 3148 KB Output is correct
18 Correct 13 ms 3116 KB Output is correct
19 Correct 15 ms 3168 KB Output is correct
20 Correct 24 ms 3156 KB Output is correct
21 Correct 27 ms 3168 KB Output is correct
22 Correct 24 ms 3140 KB Output is correct
23 Correct 25 ms 3136 KB Output is correct
24 Correct 27 ms 3244 KB Output is correct