제출 #1245410

#제출 시각아이디문제언어결과실행 시간메모리
1245410AMel0nStove (JOI18_stove)C++20
100 / 100
16 ms1476 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,N) for(ll i = 0; i < N; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second signed main() { cin.tie(0); ios::sync_with_stdio(false); ll N, K; cin >> N >> K; K--; priority_queue<ll> gap; ll pr = -1; ll tot; FOR(i, N) { ll t; cin >> t; if (pr != -1) gap.push(t-pr-1); if (i == 0) tot = -t; if (i == N-1) tot += t+1; pr = t; } while(gap.size() && K) { K--; tot -= gap.top(); gap.pop(); } cout << tot; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...