Submission #306925

# Submission time Handle Problem Language Result Execution time Memory
306925 2020-09-26T14:30:39 Z mihai145 Stove (JOI18_stove) C++14
100 / 100
101 ms 2396 KB
#include <iostream>
#include <queue>

using namespace std;

const int NMAX = 1e5;
int N, K, a[NMAX + 2];
priority_queue < int > pq;

int main()
{
    cin >> N >> K;

    for(int i = 1; i <= N; i++)
        cin >> a[i];

    int ans = a[N] + 1 - a[1];

    for(int i = 2; i <= N; i++)
        pq.push(a[i] - a[i - 1] - 1);

    for(int i = 1; i < K; i++)
        ans -= pq.top(), pq.pop();

    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 86 ms 2292 KB Output is correct
17 Correct 87 ms 2292 KB Output is correct
18 Correct 89 ms 2292 KB Output is correct
19 Correct 93 ms 2396 KB Output is correct
20 Correct 94 ms 2292 KB Output is correct
21 Correct 99 ms 2292 KB Output is correct
22 Correct 101 ms 2292 KB Output is correct
23 Correct 99 ms 2252 KB Output is correct
24 Correct 100 ms 2292 KB Output is correct