Submission #849563

# Submission time Handle Problem Language Result Execution time Memory
849563 2023-09-15T02:35:16 Z Bach21 Stove (JOI18_stove) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
vector<int> v;
int mn,mx;
signed main()
{
    cin >> n >> k;
    int prev=0;
    for (int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        if (i==0) mn=x;
        if (i==n-1) mx=x+1;
        if (i<0) v.push_back(x-prev-1);
        prev=x;
    }
    sort(v.begin(),v.end(),greater<int>());
    int res=mx-mn;
    for (int i=0;i<k-1;i++)
    {
        res-=v[i];
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -