Submission #689364

# Submission time Handle Problem Language Result Execution time Memory
689364 2023-01-28T10:07:56 Z Acanikolic Stove (JOI18_stove) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9+7;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n),b;
    for(ll i=0;i<n;i++) cin >> a[i];
    for(ll i=1;i<n;i++) b.push_back(a[i]-a[i-1]);
    if(k>=n)
    {
        cout << n;
        return 0;
    }
    if(k==1)
    {
        cout << a[n-1]+1-a[0];
        return 0;
    }
    ll R=k;
    ll treba=n-k;
    sort(b.begin(),b.end());
    for(ll i=0;i<treba;i++)
    {
        R+=b[i];
        cout << b[i] << endl;
    }
    cout << R;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -