Submission #987591

#TimeUsernameProblemLanguageResultExecution timeMemory
987591TsaganaStove (JOI18_stove)C++14
100 / 100
21 ms3200 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define lb lower_bound #define ub upper_bound #define pb push_back #define eb emplace_back #define F first #define S second using namespace std; void solve () { int n, match; cin >> n >> match; match--; pq<int> q; vector<int> v; for (int i = 0; i < n; i++) { int a1; cin >> a1; if (i) q.push(a1 - v.back() - 1); v.pb(a1); } int ans = v.back() - v[0] + 1; while ((match > 0) && (!q.empty())) { ans -= q.top(); q.pop(); match--; } cout << ans; } signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...