Submission #1010226

# Submission time Handle Problem Language Result Execution time Memory
1010226 2024-06-28T13:42:19 Z baotoan655 Stove (JOI18_stove) C++14
100 / 100
15 ms 2300 KB
#include <bits/stdc++.h>
#define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FOD(i, b, a) for(int i = (b); i >= (a); --i)
#define ll long long
#define fi first 
#define se second

using namespace std;

const int N = 1e5 + 5;
int n, k;
int t[N], d[N];

void solve(int tc) {
    cin >> n >> k;
    FOR(i, 1, n) cin >> t[i];
    FOR(i, 1, n - 1) d[i] = t[i + 1] - (t[i] + 1);
    int ans = t[n] + 1 - t[1];
    sort(d + 1, d + n, greater<int>());
    for(int i = 1; i < k; ++i) {
        ans -= d[i];
    }
    cout << ans;
    return;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int tc = 1; 
    // cin >> tc;
    for(int i = 1; i <= tc; ++i) solve(tc);
    return (0);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 13 ms 2140 KB Output is correct
17 Correct 14 ms 2140 KB Output is correct
18 Correct 15 ms 2140 KB Output is correct
19 Correct 13 ms 2140 KB Output is correct
20 Correct 13 ms 2300 KB Output is correct
21 Correct 13 ms 2204 KB Output is correct
22 Correct 13 ms 2136 KB Output is correct
23 Correct 14 ms 2124 KB Output is correct
24 Correct 13 ms 2136 KB Output is correct