답안 #93776

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93776 2019-01-11T04:53:54 Z silxikys Stove (JOI18_stove) C++14
100 / 100
21 ms 2192 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 1e5+5;
int N, K, a[maxn];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> K;
    vector<int> spaces;
    spaces.reserve(N-1);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (i > 0) spaces.push_back(a[i]-a[i-1]-1);
    }
    sort(spaces.begin(),spaces.end(),greater<int>());
    int tot = a[N-1] + 1 - a[0];
    for (int i = 0; i < K - 1; i++) {
        tot -= spaces[i];
    }
    cout << tot << '\n';


    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 20 ms 2040 KB Output is correct
17 Correct 21 ms 2012 KB Output is correct
18 Correct 20 ms 2044 KB Output is correct
19 Correct 21 ms 2192 KB Output is correct
20 Correct 20 ms 2040 KB Output is correct
21 Correct 20 ms 2096 KB Output is correct
22 Correct 20 ms 2172 KB Output is correct
23 Correct 20 ms 2024 KB Output is correct
24 Correct 20 ms 2040 KB Output is correct