답안 #754624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754624 2023-06-08T07:12:43 Z Niko_shmiko Stove (JOI18_stove) C++17
100 / 100
49 ms 1056 KB
#include<bits/stdc++.h>
using namespace std;

int n, k, t, ans;

int main(){
    cin >> n >> k;
    int a[n], in[n-1];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    ans=a[n-1]-a[0]+1;
    for(int i=0; i<n-1; i++){
        in[i]=a[i+1]-a[i]-1;
    }
    sort(in, in+n-1);
    for(int i=0; i<k-1; i++){
        ans-=in[n-2-i];
    }
    cout << ans;
}
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 47 ms 980 KB Output is correct
17 Correct 49 ms 1052 KB Output is correct
18 Correct 42 ms 980 KB Output is correct
19 Correct 46 ms 1056 KB Output is correct
20 Correct 44 ms 1052 KB Output is correct
21 Correct 43 ms 980 KB Output is correct
22 Correct 42 ms 980 KB Output is correct
23 Correct 46 ms 1052 KB Output is correct
24 Correct 42 ms 980 KB Output is correct