Submission #570652

# Submission time Handle Problem Language Result Execution time Memory
570652 2022-05-30T23:08:36 Z kkkkkkkk Stove (JOI18_stove) C++17
100 / 100
53 ms 1360 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    vector<int> v;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
        if (i>0)
            v.push_back(a[i]-a[i-1]-1);
    }
    sort(v.begin(),v.end());
    long long vk=a[n-1]-a[0]+1;
    k--;
    while (k>0&&v.size()>0)
    {
        vk-=v.back();
        v.pop_back();
        k--;
    }
    cout << vk;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 50 ms 1232 KB Output is correct
17 Correct 44 ms 1224 KB Output is correct
18 Correct 48 ms 1328 KB Output is correct
19 Correct 45 ms 1300 KB Output is correct
20 Correct 46 ms 1360 KB Output is correct
21 Correct 45 ms 1292 KB Output is correct
22 Correct 44 ms 1232 KB Output is correct
23 Correct 44 ms 1252 KB Output is correct
24 Correct 53 ms 1232 KB Output is correct