Submission #954293

# Submission time Handle Problem Language Result Execution time Memory
954293 2024-03-27T15:19:02 Z hoanganh_siuuuuuuuu Stove (JOI18_stove) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
#define int long long
#define f(i, a, b) for(int i = a; i <= b; i++)
#define fr(i, a, b) for(int i = a; i >= b; i--)
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define in insert
#define vvec vector<vector<int>>
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const int N = 1e5 + 5;
const int M = 1e3 + 5;
int n, k, a[N], f[M][M];
vector <int> z;

signed main()
{
    fast;
    cin >> n >> k;
    f(i, 1, n) cin >> a[i];

    int res = a[n] + 1 - a[1];
    f(i, 1, n - 1) z.eb(a[i + 1] - a[i]);
    sort(z.begin(), z.end(), greater <int> {});

    f(i, 0, k - 2) res -= z[i];

    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -