답안 #932892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932892 2024-02-24T11:12:47 Z Regulus Stove (JOI18_stove) C++17
100 / 100
21 ms 2524 KB
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define bug(x) cerr << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
//#define TEST
const int N = 1e5+5;
int a[N];
priority_queue<int, vector<int>, greater<int> > pq;

int main(void)
{ IO
    int n, i, K, cur, ans = 0;

    cin >> n >> K;
    for (i=1; i <= n; ++i) cin >> a[i];
    for (i=2; i <= n; ++i) pq.push(a[i]-a[i-1]-1);

    ans = cur = n;
    while (cur > K)
    {
        ans += pq.top(); pq.pop();
        --cur;
    }

    cout << ans << '\n';


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 476 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 476 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 19 ms 2268 KB Output is correct
17 Correct 19 ms 2264 KB Output is correct
18 Correct 19 ms 2268 KB Output is correct
19 Correct 21 ms 2272 KB Output is correct
20 Correct 15 ms 2524 KB Output is correct
21 Correct 10 ms 2244 KB Output is correct
22 Correct 10 ms 2364 KB Output is correct
23 Correct 10 ms 2352 KB Output is correct
24 Correct 10 ms 2272 KB Output is correct