Submission #492831

# Submission time Handle Problem Language Result Execution time Memory
492831 2021-12-09T06:53:19 Z watoKE Stove (JOI18_stove) C++17
100 / 100
48 ms 2020 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int n,m,a,b,c,cnt,g,f,d,e,cvp,k;
int dizi[100005];
int fark[100005];

int main()
{
    cin>>n>>k;
    for (int i=0;i<n;i++)
        cin>>dizi[i];
    for (int i=0;i<n-1;i++)
        fark[i]=dizi[i+1]-dizi[i]-1;
    sort(fark,fark+n-1);
    reverse(fark,fark+n-1);
    cvp=dizi[n-1]-dizi[0]+1;
    for (int i=0;i<k-1;i++)
         cvp-=fark[i];
    cout<<cvp;
    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 1 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 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 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 1 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 1 ms 204 KB Output is correct
8 Correct 0 ms 204 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 332 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 460 KB Output is correct
15 Correct 2 ms 316 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 1 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 1 ms 204 KB Output is correct
8 Correct 0 ms 204 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 332 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 460 KB Output is correct
15 Correct 2 ms 316 KB Output is correct
16 Correct 42 ms 1912 KB Output is correct
17 Correct 48 ms 1976 KB Output is correct
18 Correct 42 ms 1976 KB Output is correct
19 Correct 45 ms 2016 KB Output is correct
20 Correct 42 ms 1944 KB Output is correct
21 Correct 43 ms 2020 KB Output is correct
22 Correct 46 ms 2008 KB Output is correct
23 Correct 44 ms 1988 KB Output is correct
24 Correct 43 ms 1972 KB Output is correct