Submission #520604

# Submission time Handle Problem Language Result Execution time Memory
520604 2022-01-30T10:06:38 Z ddy888 Stove (JOI18_stove) C++17
100 / 100
25 ms 3180 KB
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long 
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;  
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int N, K, A[100010], ans;
vector<int> blank;

signed main() {
    fast;
    cin >> N >> K;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }
    sort(A + 1, A + 1 + N);
    for (int i = 1; i <= N - 1; ++i) {
        blank.pb(A[i + 1] - A[i] - 1);
    }
    ans = A[N] + 1 - A[1];
    sort(blank.begin(), blank.end(), greater<int>());
    for (int i = 0; i < K - 1; ++i) {
        ans -= blank[i];
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 22 ms 3144 KB Output is correct
17 Correct 25 ms 3140 KB Output is correct
18 Correct 24 ms 3116 KB Output is correct
19 Correct 18 ms 3140 KB Output is correct
20 Correct 19 ms 3148 KB Output is correct
21 Correct 19 ms 3140 KB Output is correct
22 Correct 24 ms 3124 KB Output is correct
23 Correct 19 ms 3180 KB Output is correct
24 Correct 19 ms 3164 KB Output is correct