Submission #1029519

# Submission time Handle Problem Language Result Execution time Memory
1029519 2024-07-21T02:37:10 Z nisanduu Stove (JOI18_stove) C++14
100 / 100
37 ms 3328 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n),arr;
    for(ll i=0;i<n;i++) cin>>v[i];
    ll tot = v[n-1] - v[0] + 1;
    for(ll i=1;i<n;i++) arr.push_back(v[i] - v[i-1] - 1);
    sort(arr.begin(),arr.end(),greater<ll>());
    for(ll i=0;i<(k-1);i++) tot -= arr[i];
    cout<<tot<<endl;
}
int main()
{
    solve();

    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 348 KB Output is correct
6 Correct 1 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 0 ms 348 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 348 KB Output is correct
6 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 480 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 448 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 348 KB Output is correct
6 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 480 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 448 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 31 ms 3248 KB Output is correct
17 Correct 33 ms 3276 KB Output is correct
18 Correct 32 ms 3248 KB Output is correct
19 Correct 30 ms 3320 KB Output is correct
20 Correct 30 ms 3284 KB Output is correct
21 Correct 30 ms 3284 KB Output is correct
22 Correct 30 ms 3276 KB Output is correct
23 Correct 37 ms 3276 KB Output is correct
24 Correct 30 ms 3328 KB Output is correct