답안 #797886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797886 2023-07-30T04:58:43 Z MVP_Harry Stove (JOI18_stove) C++17
100 / 100
16 ms 2172 KB
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define rep(i, m, n) for (int i = m; i <= n; i++)
#define per(i, m, n) for (int i = m; i >= n; i--)

const int maxn = 1e5 + 5;

int n, k;
int a[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> k;
    
    vector<int> d;
    cin >> a[1];
    rep(i, 2, n) {
        cin >> a[i];
        d.push_back(a[i] - a[i - 1] - 1);
    }

    int ans = a[n] - a[1] + 1;
    sort(begin(d), end(d), greater<int>());
    rep(i, 1, k - 1) {
        ans -= d[i - 1];
    }

    cout << ans << endl;
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 14 ms 2096 KB Output is correct
17 Correct 14 ms 2132 KB Output is correct
18 Correct 16 ms 2120 KB Output is correct
19 Correct 14 ms 2128 KB Output is correct
20 Correct 14 ms 2132 KB Output is correct
21 Correct 14 ms 2164 KB Output is correct
22 Correct 14 ms 2132 KB Output is correct
23 Correct 14 ms 2172 KB Output is correct
24 Correct 14 ms 2132 KB Output is correct