Submission #908691

#TimeUsernameProblemLanguageResultExecution timeMemory
908691a_l_i_r_e_z_aStove (JOI18_stove)C++17
100 / 100
17 ms2524 KiB
// In the name of God #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pii; typedef pair<ll, ll> pll; #define pb push_back #define S second #define F first #define mp make_pair #define smax(x, y) (x) = max((x), (y)) #define smin(x, y) (x) = min((x), (y)) #define all(x) (x).begin(), (x).end() #define len(x) ((ll)(x).size()) const int maxn = 1e5 + 5; const int inf = 1e9 + 7; int n, k, a[maxn]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for(int i = 0; i < n; i++) cin >> a[i]; vector<int> vec; for(int i = 1; i < n; i++) vec.pb(a[i] - a[i - 1] - 1); sort(all(vec)); int ans = n; for(int i = 0; i < n - k; i++) ans += vec[i]; cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...