제출 #295761

#제출 시각아이디문제언어결과실행 시간메모리
295761aZvezdaStove (JOI18_stove)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" typedef long long ll; typedef long double ld; typedef unsigned long long ull; template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } const ll mod = 1e9 + 7; template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}} #define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll last = -1; ll n, k; cin >> n >> k; if(n == 1) { cout << 2 << endl; return 0; } ll total = 0; priority_queue<ll> pq; for(ll i = 0; i < n; i ++) { ll t; cin >> t; if(i != 0) { pq.push(t - last - 1); } else { total -= t; } last = t; } total += last + 1; while(k > 1) { total -= pq.top(); pq.pop(); k --; } cout << total << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...