Submission #651137

# Submission time Handle Problem Language Result Execution time Memory
651137 2022-10-17T10:51:43 Z PagodePaiva Stove (JOI18_stove) C++14
0 / 100
1 ms 212 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];

    priority_queue <int> pq;

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

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

    cout << res << "\n"; 

    return 0;   
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -