답안 #47123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47123 2018-04-27T20:50:41 Z dqhungdl Stove (JOI18_stove) C++17
100 / 100
77 ms 10404 KB
#include <bits/stdc++.h>
using namespace std;

int n,k,a[100005],b[100005];

int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++)
        b[i]=a[i+1]-a[i]-1;
    sort(b+1,b+n+1,greater<int>());
    int res=a[n]-a[1]+1;
    for(int i=1;i<k;i++)
        res-=b[i];
    cout<<res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 440 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 576 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 440 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 576 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 3 ms 748 KB Output is correct
11 Correct 3 ms 780 KB Output is correct
12 Correct 4 ms 848 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 3 ms 944 KB Output is correct
15 Correct 3 ms 1056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 440 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 576 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 3 ms 748 KB Output is correct
11 Correct 3 ms 780 KB Output is correct
12 Correct 4 ms 848 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 3 ms 944 KB Output is correct
15 Correct 3 ms 1056 KB Output is correct
16 Correct 62 ms 2948 KB Output is correct
17 Correct 60 ms 3712 KB Output is correct
18 Correct 59 ms 4680 KB Output is correct
19 Correct 58 ms 5584 KB Output is correct
20 Correct 60 ms 6568 KB Output is correct
21 Correct 77 ms 7564 KB Output is correct
22 Correct 60 ms 8476 KB Output is correct
23 Correct 60 ms 9444 KB Output is correct
24 Correct 59 ms 10404 KB Output is correct