Submission #392325

# Submission time Handle Problem Language Result Execution time Memory
392325 2021-04-20T19:27:44 Z wildturtle Stove (JOI18_stove) C++14
100 / 100
60 ms 3224 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define sc second
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l,idx,B[500005],le,ri,mid,ans;
ll A[500005];
vector <ll> v;
int main() {
    cin>>n>>k;
    for(ll i=1;i<=n;i++) {
        cin>>A[i];
    }
    if(n==1) { cout<<1; return 0; }
    sort(A+1,A+1+n);
    for(ll i=1;i<n;i++) {
        v.push_back(A[i+1]-A[i]-1);
    }
    sort(v.begin(),v.end());
    g=v.size()-k+1;
    for(ll i=v.size()-1;i>=max(f,g);i--) {
        a+=v[i];
    }
    cout<<(A[n]+1)-A[1]-a;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 53 ms 3120 KB Output is correct
17 Correct 54 ms 3212 KB Output is correct
18 Correct 60 ms 3188 KB Output is correct
19 Correct 58 ms 3224 KB Output is correct
20 Correct 59 ms 3132 KB Output is correct
21 Correct 53 ms 3096 KB Output is correct
22 Correct 53 ms 3132 KB Output is correct
23 Correct 54 ms 3136 KB Output is correct
24 Correct 54 ms 3104 KB Output is correct