Submission #413819

# Submission time Handle Problem Language Result Execution time Memory
413819 2021-05-29T14:44:36 Z illyakr Stove (JOI18_stove) C++14
100 / 100
59 ms 2288 KB
#include <bits/stdc++.h>

using namespace std;

int n, k;
vector<int> have;
int a[101010];
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)cin >> a[i];
    for (int i = 1; i < n; i++)
        have.push_back(a[i + 1] - a[i] - 1);
    sort(have.begin(), have.end(), greater<int>());
    int ans = a[n] - a[1] + 1;
    k--;
    for (auto i : have) {
        if (--k < 0)break;
        ans -= i;
    }
    cout << ans;
}
/**
10 5
1
2
5
6
8
11
13
15
16
20

3 2
1 3 6
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 53 ms 1320 KB Output is correct
17 Correct 54 ms 1216 KB Output is correct
18 Correct 54 ms 2168 KB Output is correct
19 Correct 56 ms 2220 KB Output is correct
20 Correct 54 ms 2240 KB Output is correct
21 Correct 55 ms 2288 KB Output is correct
22 Correct 54 ms 2240 KB Output is correct
23 Correct 55 ms 2236 KB Output is correct
24 Correct 59 ms 2280 KB Output is correct