Submission #873642

# Submission time Handle Problem Language Result Execution time Memory
873642 2023-11-15T12:21:01 Z maxFedorchuk Stove (JOI18_stove) C++14
100 / 100
33 ms 7212 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    set < long long > st;

    long long n,k,a;
    cin>>n>>k;

    for(long long i=1;i<=n;i++)
    {
        cin>>a;
        st.insert(a);
    }
    long long res=st.size();


    vector < long long > vid;

    long long mun=-1;
    for(auto u:st)
    {
        if(mun!=-1)
        {
            vid.push_back(u-(mun+1));
        }

        mun=u;
    }

    sort(vid.begin(),vid.end());

    long long ndob=st.size()-k;
    for(long long i=0;i<ndob;i++)
    {
        res+=vid[i];
    }

    cout<<res<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 608 KB Output is correct
12 Correct 1 ms 608 KB Output is correct
13 Correct 1 ms 572 KB Output is correct
14 Correct 1 ms 608 KB Output is correct
15 Correct 1 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 608 KB Output is correct
12 Correct 1 ms 608 KB Output is correct
13 Correct 1 ms 572 KB Output is correct
14 Correct 1 ms 608 KB Output is correct
15 Correct 1 ms 612 KB Output is correct
16 Correct 31 ms 7200 KB Output is correct
17 Correct 33 ms 7124 KB Output is correct
18 Correct 32 ms 7180 KB Output is correct
19 Correct 31 ms 7124 KB Output is correct
20 Correct 30 ms 7124 KB Output is correct
21 Correct 30 ms 7124 KB Output is correct
22 Correct 30 ms 7112 KB Output is correct
23 Correct 31 ms 7212 KB Output is correct
24 Correct 32 ms 7184 KB Output is correct