Submission #369087

# Submission time Handle Problem Language Result Execution time Memory
369087 2021-02-20T09:21:33 Z Lam_lai_cuoc_doi Stove (JOI18_stove) C++17
100 / 100
64 ms 2944 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

const bool typetest = 0;
const int N = 1e5 + 5;
int n, k;
ll a[N], b[N];

void Read()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i < n; ++i)
        b[i] = a[i + 1] - a[i];
}

void Solve()
{
    sort(b + 1, b + n);
    a[n] -= a[1];
    for (int i = n - 1; i >= n - k + 1; --i)
        a[n] -= b[i];
    cout << a[n] + k;
}

int32_t main()
{
    //ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t(1);
    if (typetest)
        cin >> t;
    for (int _ = 1; _ <= t; ++_)
    {
        Read();
        Solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 64 ms 2796 KB Output is correct
17 Correct 51 ms 2832 KB Output is correct
18 Correct 47 ms 2796 KB Output is correct
19 Correct 57 ms 2796 KB Output is correct
20 Correct 47 ms 2796 KB Output is correct
21 Correct 47 ms 2796 KB Output is correct
22 Correct 58 ms 2944 KB Output is correct
23 Correct 56 ms 2824 KB Output is correct
24 Correct 49 ms 2796 KB Output is correct