Submission #1033573

#TimeUsernameProblemLanguageResultExecution timeMemory
1033573quannnguyen2009Stove (JOI18_stove)C++14
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> #define int long long #define fi first #define se second #define pb push_back #define ii pair<int, int> #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() using namespace std; const int N=1e5+5, mod = 1e9+7, inf = 1e18; int n, k; int a[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i=1; i<=n; i++) cin >> a[i]; vector<int> b; for (int i=2; i<=n; i++) { b.pb(a[i]-a[i-1]-1); } sort(all(b), greater<int>()); int cnt = 0; for (int i=0; i<k-1; i++) cnt += b[i]; cout << a[n]-cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...