Submission #591995

# Submission time Handle Problem Language Result Execution time Memory
591995 2022-07-08T11:03:55 Z ozed Stove (JOI18_stove) C++14
100 / 100
45 ms 1084 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;



int main(){

int n,k,out=0;
cin>>n>>k;
vi v(n);
vi gap(n-1);
for(int i=0;i<n;i++){
    cin>>v[i];
}
for(int i=0;i<n-1;i++){
    gap[i]=v[i+1]-v[i]-1;
}
out=v[n-1]+1-v[0];
sort(gap.rbegin(),gap.rend());
for(int i=0;i<k-1;i++){
    out-=gap[i];
}
cout<<out;
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 44 ms 1032 KB Output is correct
17 Correct 43 ms 980 KB Output is correct
18 Correct 45 ms 980 KB Output is correct
19 Correct 43 ms 980 KB Output is correct
20 Correct 44 ms 980 KB Output is correct
21 Correct 42 ms 980 KB Output is correct
22 Correct 41 ms 980 KB Output is correct
23 Correct 43 ms 980 KB Output is correct
24 Correct 43 ms 1084 KB Output is correct