Submission #1033581

# Submission time Handle Problem Language Result Execution time Memory
1033581 2024-07-25T04:03:47 Z coin_ Stove (JOI18_stove) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    cin.tie(nullptr) -> sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    priority_queue<int> pq;
    vector<int> t(n+5);
    for (int i = 1; i <= n; i++){
        cin >> t[i];
    }
    for (int i = 2; i <= n; i++){
        pq.push(t[i] - t[i-1] - 1);
    }
    k--;
    int ans = t[n];
    while(!pq.empty() && k){
        ans -= pq.top();
        pq.pop();
        k--;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -