Submission #450345

# Submission time Handle Problem Language Result Execution time Memory
450345 2021-08-02T15:08:41 Z JovanB Stove (JOI18_stove) C++17
100 / 100
24 ms 2068 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
int niz[100005];
int g[100005];
 
int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;
 
    int n, k;
    cin >> n >> k;
    k--;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
    }
    for(int i=2; i<=n; i++){
        g[i] = niz[i] - niz[i-1] - 1;
    }
    sort(g+1, g+1+n);
    reverse(g+1, g+1+n);
    int res = niz[n]+1-niz[1];
    for(int i=1; i<=k; i++) res -= g[i];
    cout << res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 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 1 ms 204 KB Output is correct
9 Correct 0 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 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 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 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 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 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 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 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 21 ms 1996 KB Output is correct
17 Correct 24 ms 1996 KB Output is correct
18 Correct 21 ms 1996 KB Output is correct
19 Correct 21 ms 2064 KB Output is correct
20 Correct 21 ms 1996 KB Output is correct
21 Correct 21 ms 2064 KB Output is correct
22 Correct 21 ms 2052 KB Output is correct
23 Correct 21 ms 2068 KB Output is correct
24 Correct 21 ms 1996 KB Output is correct