Submission #278084

#TimeUsernameProblemLanguageResultExecution timeMemory
278084AhmetYahyaStove (JOI18_stove)C++17
100 / 100
100 ms2412 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, mina; priority_queue<int > v; int32_t main(){ cin >> n >> k; k--; cin >> b; mak = b; mina = b; for (int i = 1; i < n; i++){ cin >> a; v.push(a-b); // cout << a-b << endl; b = a; mak = max(a, mak); mina = min(a, mina); } while(k > 0){ k--; mak -= (v.top()-1); v.pop(); } cout << mak-mina+1 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...