제출 #561186

#제출 시각아이디문제언어결과실행 시간메모리
561186BobonbushStove (JOI18_stove)C++17
100 / 100
23 ms2164 KiB
#include <bits/stdc++.h> #define foreach for #define in : using namespace std; typedef long long ll; /* Konichiwa Konichiwa Ara ~~ ara Bob no taisuki - Shinobu Kocho * * * * * * * * * * * I love SHINOBU <3 <3 <3 * * * * * * * * * */ /* _________________________ Author : Bob15324 _________________________ */ template<class X , class Y> bool Minimize(X & x , Y y) { if(x == -1 || x >y) { x = y; return true; } return false; } template<class X , class Y> bool Maximize(X & x , Y y) { if( x < y) { x = y; return true; } return false; } /* End of templates. Let's see what do we have here */ const int N = 1e5+1; int n , k; int a[N]; int main() { ios_base :: sync_with_stdio(0);cin.tie(0); cin >> n >> k; int kay = n; int res = n; priority_queue<int , vector<int> , greater<int> >pq; for(int i = 1 ; i <= n ; i++) { cin >> a[i]; if(i > 1) { pq.push(a[i] - a[i-1] - 1); } } while(kay > k && !pq.empty()) { res += pq.top(); pq.pop(); kay--; } cout << res ; return 0; } //Ehem. My code is amazing. Pay me 2$.Thank you.
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...