제출 #278079

#제출 시각아이디문제언어결과실행 시간메모리
278079AhmetYahyaStove (JOI18_stove)C++17
0 / 100
1 ms256 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb push_back #define st first #define nd second #define lb lower_bound const int N = 4000050; int n, k, a, b, mak; priority_queue<int> v; vector<int> u; int32_t main(){ cin >> n >> k; k--; for (int i = 0; i < n; i++){ cin >> a; u.pb(a); } sort(u.begin(), u.end(), greater<int>()); for (int i = 0; i < n-1; i++){ v.push(u[i]-u[i+1]); // cout << u[i]-u[i+1] << endl; } while(k > 0){ k--; // cout << v.top()-1 << endl; mak -= (v.top()-1); v.pop(); } cout << u[0]+mak << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...