Submission #739178

# Submission time Handle Problem Language Result Execution time Memory
739178 2023-05-10T06:25:55 Z tooxpert Stove (JOI18_stove) C++17
100 / 100
58 ms 2672 KB
//designed by tooxpert
#include<bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define sl set<ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define s second
#define f first
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
int main()
{
    ll n, k, i, s;
    cin >> n >> k;
    vl v(n);
    for(ll&h : v)  cin >>h;
    priority_queue<int>pq;
    for(i = 1; i < n; i++)  pq.push(v[i]-v[i-1]-1);
    s = v[n-1] - v[0] + 1;
    for(i = 0; i < k - 1; i++)
    {
        auto p = pq.top();
        pq.pop();
        s -= p;
    }
    cout << s <<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 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 2 ms 356 KB Output is correct
11 Correct 2 ms 312 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 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 2 ms 356 KB Output is correct
11 Correct 2 ms 312 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 308 KB Output is correct
16 Correct 43 ms 2588 KB Output is correct
17 Correct 38 ms 2604 KB Output is correct
18 Correct 40 ms 2632 KB Output is correct
19 Correct 48 ms 2612 KB Output is correct
20 Correct 44 ms 2600 KB Output is correct
21 Correct 51 ms 2672 KB Output is correct
22 Correct 58 ms 2584 KB Output is correct
23 Correct 50 ms 2584 KB Output is correct
24 Correct 47 ms 2632 KB Output is correct