Submission #843924

# Submission time Handle Problem Language Result Execution time Memory
843924 2023-09-04T17:06:23 Z Elvin_Fritl Stove (JOI18_stove) C++17
100 / 100
46 ms 2340 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 25;

int32_t main()
{

    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int res = a[n] + 1 - a[1];
    priority_queue<int>q;
    for(int i=2;i<=n;i++){
        q.push(a[i] - a[i-1] - 1);
    }
    k--;
    while(k--){
        res -= q.top();
        q.pop();
    }
    cout<<res<<endl;

    return 0;
}
/*

1 1    2 2    3 3    4 4
1


*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 432 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 1 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 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 432 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 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 432 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 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 30 ms 2336 KB Output is correct
17 Correct 32 ms 2312 KB Output is correct
18 Correct 32 ms 2252 KB Output is correct
19 Correct 31 ms 2260 KB Output is correct
20 Correct 46 ms 2296 KB Output is correct
21 Correct 38 ms 2256 KB Output is correct
22 Correct 39 ms 2264 KB Output is correct
23 Correct 39 ms 2252 KB Output is correct
24 Correct 39 ms 2340 KB Output is correct