제출 #666335

#제출 시각아이디문제언어결과실행 시간메모리
666335I_love_Chou_GiangStove (JOI18_stove)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a, b) for (ll i = (a); i <= (b); ++i) #define per(i, a, b) for (ll i = (a); i <= (b); --i) #define each(i, a) for (auto i : a) #define all(x) x.begin(), x.end() #define sz(x) int(x.size()) template<typename T> inline bool ckmax(T&x, T y) { if (x >= y) return false; x = y; return true; } template<typename T> inline bool ckmin(T&x, T y) { if (x <= y) return false; x = y; return true; } const int MOD = int(1e9) + 7, naxm = 100000; int N, K, T[naxm + 5]; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); cin >> N >> K; rep(i, 1, N) cin >> T[i]; int ans = T[N]; priority_queue<int> que; rep(i, 1, N - 1) que.push(T[i + 1] - T[i] - 1); --K; while (que.size()) { if (!K) break; --K; ans -= que.top(); que.pop(); } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...