답안 #918268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918268 2024-01-29T14:02:46 Z vjudge1 Stove (JOI18_stove) C++14
100 / 100
42 ms 2896 KB




#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define  file(name)  freopen(name".inp", "r", stdin);\
                     freopen(name".out", "w", stdout);
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define TIME        (1.0 * clock() / CLOCKS_PER_SEC)
#define all(a)      a.begin(),a.end()
#define endl        "\n"
#define all1(a)     a+1,a+n+1
#define unordered_map  map
#define Accepted 0      
// #define push_back   emplace_back
// #define gcd(a,b)    __gcd(a,b);
// #define lcm(a,b)    (a*b)/gcd(a,b);

const long long INF = (long long)1e9;
const long long MOD = (long long)1e9+7;
const long long MODD = 14062008; /// 998244353
const long long maxN = 2e5+9;
const long long LOG = 30;







///--------------------------------


void solve();

int main(){






    long long t;


    // cin >> t;

    t=1;



    while (t--){




        solve();


    }






    return Accepted;
}



///--------------------[PROBLEM SOLUTION]--------------------///


 int n,k,ans=INF,a[200009],truoc=0;
    vector<pair<int,int>> luu;
    priority_queue<int> luu1;

void solve(){



   

    cin >> n >> k;

    int x;
    cin >> x;
    ans=x;
    truoc=x;

    for (int i=1; i<=n-1; i++){
        cin >> x;

        luu.push_back({x,x+1});

        luu1.push(x-truoc-1);
        truoc=x;
    }
    if(n==1) return cout << 1, void();


    ans=x-ans+1;

    k--;
    while (k--){
        ans-=luu1.top();
        luu1.pop();
    }


    cout << ans;



}





# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 0 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 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 0 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 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 31 ms 2756 KB Output is correct
17 Correct 32 ms 2760 KB Output is correct
18 Correct 32 ms 2768 KB Output is correct
19 Correct 32 ms 2704 KB Output is correct
20 Correct 37 ms 2768 KB Output is correct
21 Correct 40 ms 2760 KB Output is correct
22 Correct 41 ms 2756 KB Output is correct
23 Correct 41 ms 2896 KB Output is correct
24 Correct 42 ms 2768 KB Output is correct