Submission #339677

#TimeUsernameProblemLanguageResultExecution timeMemory
339677ijxjdjdStove (JOI18_stove)C++14
100 / 100
50 ms2032 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef string str; typedef double db; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pi> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define FR(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define RF(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) int main() { int N, K; cin >> N >> K; vector<int> split; int last; cin >> last; int first = last; FR(i, N-1) { int next; cin >> next; if (next - last > 1) { split.push_back(next-(last+1)); } last = next; } int rem = 0; sort(split.begin(), split.end()); for (int k = 1; k <= min(K-1, int(split.size())); k++) { rem += split[split.size()-k]; } cout << (last + 1 - first - rem); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...