Submission #896406

# Submission time Handle Problem Language Result Execution time Memory
896406 2024-01-01T11:40:13 Z SuPythony Stove (JOI18_stove) C++17
100 / 100
45 ms 3280 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k; cin>>n>>k;
    vector<int> t(n);
    vector<int> off(n,0);
    vector<pair<int,int>> diffs;
    for (int i=0; i<n; i++) {
        cin>>t[i];
        if (i>0) {
            diffs.push_back({t[i]-t[i-1]+1, i-1});
        }
    }
    sort(diffs.begin(), diffs.end(), greater<pair<int,int>>());
    for (int i=0; i<k-1; i++) {
        off[diffs[i].second]=1;
    }
    off[n-1]=1;
    int ind=0;
    long long ans=0;
    while (ind<n) {
        int start=ind;
        while (!off[ind]) {
            ind++;
        }
        ans+=(t[ind]-t[start]+1);
        ind++;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 376 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 376 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 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 544 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 376 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 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 544 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 348 KB Output is correct
16 Correct 37 ms 3280 KB Output is correct
17 Correct 38 ms 3028 KB Output is correct
18 Correct 39 ms 3024 KB Output is correct
19 Correct 40 ms 3024 KB Output is correct
20 Correct 37 ms 3180 KB Output is correct
21 Correct 36 ms 3128 KB Output is correct
22 Correct 37 ms 3044 KB Output is correct
23 Correct 45 ms 3024 KB Output is correct
24 Correct 40 ms 3104 KB Output is correct