답안 #507522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
507522 2022-01-12T16:15:31 Z maco1503 Stove (JOI18_stove) C++14
0 / 100
1 ms 972 KB
#include <bits/stdc++.h>
#define rpd ios_base :: sync_with_stdio(0); cin.tie(0);
#define ll long long
#define fs first
#define sc second
#define pb push_back
#define mod 666013
#define NMAX 100000 + 5

using namespace std;




int main()
{
    rpd;
    int v[NMAX]={0},t[NMAX]={0};
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>v[i];
    sort(v+1,v+1+n);
    for(int i=1;i<n;i++)t[i]=v[i+1]-v[i]-1;
    sort(t+1,t+1+n);
    int ans=v[n]-v[1]+1;
    for(int i=n-1;i>=n-k+1;i--)ans-=t[i];
    cout<<ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Incorrect 1 ms 972 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Incorrect 1 ms 972 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Incorrect 1 ms 972 KB Output isn't correct
4 Halted 0 ms 0 KB -