Submission #106873

# Submission time Handle Problem Language Result Execution time Memory
106873 2019-04-20T19:24:49 Z FiloSanza Stove (JOI18_stove) C++14
100 / 100
34 ms 2432 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    int N, K;
    int ans = 0;
    cin >> N >> K;

    vector<int> v(N);
    for(auto &i : v) cin >> i;
    sort(v.begin(), v.end());

    ans = v.back() - v.front() + 1;
    priority_queue<int> diff;

    for(int i=1; i<N; i++) diff.push(v[i]-v[i-1]-1);

    while(--K && !diff.empty())
        ans -= diff.top(), diff.pop();
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 404 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 404 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 17 ms 2432 KB Output is correct
17 Correct 18 ms 2432 KB Output is correct
18 Correct 19 ms 2424 KB Output is correct
19 Correct 20 ms 2424 KB Output is correct
20 Correct 24 ms 2304 KB Output is correct
21 Correct 32 ms 2396 KB Output is correct
22 Correct 34 ms 2424 KB Output is correct
23 Correct 29 ms 2404 KB Output is correct
24 Correct 29 ms 2432 KB Output is correct