답안 #648184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
648184 2022-10-05T16:30:35 Z Irocans Stove (JOI18_stove) C++14
100 / 100
54 ms 664 KB
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,k,i,b;
    cin >> n>>k;
    k--;
    int a[n];
    cin >> a[0];
    b=a[0];
    for (i=1;i<n;i++) {
        cin >> a[i];
        a[i-1]=a[i]-a[i-1]-1;
    }
    b=a[n-1]-b+1;
    sort(a,a+n-1);
    i=n-2;
    while (k>0) {
        b=b-a[i];
        i--;
        k--;
    }
    cout << b;
    return 0;
}
# 결과 실행 시간 메모리 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 1 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 1 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 1 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 1 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 1 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 1 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 45 ms 596 KB Output is correct
17 Correct 44 ms 664 KB Output is correct
18 Correct 53 ms 596 KB Output is correct
19 Correct 54 ms 664 KB Output is correct
20 Correct 45 ms 596 KB Output is correct
21 Correct 46 ms 660 KB Output is correct
22 Correct 42 ms 596 KB Output is correct
23 Correct 44 ms 660 KB Output is correct
24 Correct 44 ms 596 KB Output is correct