Submission #503588

# Submission time Handle Problem Language Result Execution time Memory
503588 2022-01-08T11:27:58 Z lucri Stove (JOI18_stove) C++17
100 / 100
56 ms 700 KB
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,t[100010],ans;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;++i)
        cin>>t[i];
    sort(t+1,t+n+1);
    ans=t[n]+1-t[1];
    for(int i=1;i<n;++i)
        t[i]=t[i+1]-t[i]-1;
    sort(t+1,t+n);
    for(int i=n-1;i>0&&i>=n-k+1;--i)
        ans-=t[i];
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 3 ms 312 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 3 ms 312 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 44 ms 612 KB Output is correct
17 Correct 44 ms 608 KB Output is correct
18 Correct 42 ms 572 KB Output is correct
19 Correct 43 ms 668 KB Output is correct
20 Correct 49 ms 700 KB Output is correct
21 Correct 56 ms 564 KB Output is correct
22 Correct 48 ms 580 KB Output is correct
23 Correct 48 ms 576 KB Output is correct
24 Correct 42 ms 628 KB Output is correct