답안 #734760

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734760 2023-05-03T04:39:13 Z rahidilbayramli Stove (JOI18_stove) C++17
100 / 100
50 ms 2632 KB
#include<bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define sl set<ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define s second
#define f first
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
int main()
{
    ll n, k, i, s;
    cin >> n >> k;
    vl v(n);
    for(ll&h : v)    cin >> h;
    priority_queue<int>pq;
    for(i = 1; i < n; i++)    pq.push(v[i]-v[i-1]-1);
    s = v[n-1] - v[0] + 1;
    for(i = 0; i < k - 1; i++)
    {
        auto p = pq.top();
        pq.pop();
        s -= p;
    }
    cout << s << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 40 ms 2588 KB Output is correct
17 Correct 40 ms 2632 KB Output is correct
18 Correct 40 ms 2604 KB Output is correct
19 Correct 42 ms 2592 KB Output is correct
20 Correct 45 ms 2592 KB Output is correct
21 Correct 47 ms 2600 KB Output is correct
22 Correct 50 ms 2608 KB Output is correct
23 Correct 49 ms 2604 KB Output is correct
24 Correct 47 ms 2604 KB Output is correct