Submission #948725

#TimeUsernameProblemLanguageResultExecution timeMemory
948725phoenix0423Stove (JOI18_stove)C++17
100 / 100
19 ms2664 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pll; #define fastio ios::sync_with_stdio(false), cin.tie(0) #define pb push_back #define eb emplace_back #define f first #define s second #define lowbit(x) x&-x const int maxn = 2e5 + 5; signed main(void){ fastio; int n, k; cin>>n>>k; vector<int> a(n); for(int i = 0; i < n; i++) cin>>a[i]; int ans = n; vector<int> val; for(int i = 1; i < n; i++) val.pb(a[i] - a[i - 1] - 1); sort(val.begin(), val.end()); int use = n - k; for(int i = 0; i < use; i++) ans += val[i]; cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...