Submission #1097630

# Submission time Handle Problem Language Result Execution time Memory
1097630 2024-10-07T17:21:18 Z sax Stove (JOI18_stove) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define int long long
///#define pragma GCC optimise("O3")

using namespace std;

signed main()
{
    int n, k; cin>>n>>k;
    vector <int> dif;
    int aux=0, all=0;
    for (int i=1; i<=n; i++)
    {
        int a; cin>>a;
        if (i>1) dif.push_back(a-aux);
        if (i==1) all=a;
        if (i==n) all=a+1-all;
        aux=a+1;
    }

    sort(dif.begin(), dif.end(), greater<int>());

    k--;
    for (auto x:dif)
    {
        k--;
        all-=x;
        if (k==0) break;
    }
    cout<<all<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -