답안 #849565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849565 2023-09-15T02:36:11 Z Bach21 Stove (JOI18_stove) C++14
100 / 100
35 ms 2512 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
vector<int> v;
int mn,mx;
signed main()
{
    cin >> n >> k;
    int prev=0;
    for (int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        if (i==0) mn=x;
        if (i==n-1) mx=x+1;
        if (i>0) v.push_back(x-prev-1);
        prev=x;
    }
    sort(v.begin(),v.end(),greater<int>());
    int res=mx-mn;
    for (int i=0;i<k-1;i++)
    {
        res-=v[i];
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 496 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 1 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 496 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 1 ms 516 KB Output is correct
16 Correct 34 ms 2512 KB Output is correct
17 Correct 35 ms 2264 KB Output is correct
18 Correct 33 ms 2260 KB Output is correct
19 Correct 33 ms 2260 KB Output is correct
20 Correct 33 ms 2304 KB Output is correct
21 Correct 34 ms 2348 KB Output is correct
22 Correct 33 ms 2260 KB Output is correct
23 Correct 33 ms 2256 KB Output is correct
24 Correct 34 ms 2260 KB Output is correct