Submission #868838

# Submission time Handle Problem Language Result Execution time Memory
868838 2023-11-02T05:01:30 Z Salty Stove (JOI18_stove) C++14
100 / 100
43 ms 2776 KB
#include<bits/stdc++.h>
#define ll long long
#define st first
#define pii pair<ll,ll>
#define nd second
#define pb push_back
using namespace std;
const int N=1e5+10;
long long arr[N];
int main(){
    int n,k;
    cin>>n>>k;
    k--;
    ll sum=0;
    for(int i=0;i<n;i++)cin>>arr[i];
    sum=arr[n-1]+1-arr[0];
    priority_queue<int> pq;
    pq.push(0);
    for(int i=1;i<n;i++){
        pq.push(arr[i]-arr[i-1]-1);
    }
    while(k--){
        sum-=pq.top();
        pq.pop();
    }
    cout<<sum;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 456 KB Output is correct
15 Correct 2 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 456 KB Output is correct
15 Correct 2 ms 452 KB Output is correct
16 Correct 30 ms 2768 KB Output is correct
17 Correct 30 ms 2764 KB Output is correct
18 Correct 31 ms 2620 KB Output is correct
19 Correct 32 ms 2764 KB Output is correct
20 Correct 36 ms 2776 KB Output is correct
21 Correct 38 ms 2776 KB Output is correct
22 Correct 38 ms 2776 KB Output is correct
23 Correct 43 ms 2772 KB Output is correct
24 Correct 38 ms 2768 KB Output is correct