답안 #547785

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
547785 2022-04-11T18:18:00 Z unicornboy Stove (JOI18_stove) C++14
100 / 100
53 ms 2796 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
const int N=5e5+1;
int main()
{
    ll n , k;
    cin >> n >> k ;
    ll arr[n+1];
    ll v[n+1];
    for (int i=0;i<n;i++)
    {
        cin >> arr[i];
        if(i!=0)
        {
            v[i-1]=arr[i]-arr[i-1]-1;
        }
    }
    sort(v,v+n-1);
    ll ans=n;
    for (int i=0;i<n-k;i++)
    {
        ans+=v[i];
    }
    cout<<ans<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 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 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 372 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 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 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 372 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 48 ms 2732 KB Output is correct
17 Correct 44 ms 2736 KB Output is correct
18 Correct 43 ms 2764 KB Output is correct
19 Correct 50 ms 2720 KB Output is correct
20 Correct 44 ms 2724 KB Output is correct
21 Correct 43 ms 2764 KB Output is correct
22 Correct 46 ms 2768 KB Output is correct
23 Correct 51 ms 2720 KB Output is correct
24 Correct 53 ms 2796 KB Output is correct