Submission #126672

#TimeUsernameProblemLanguageResultExecution timeMemory
126672toonewbieStove (JOI18_stove)C++17
100 / 100
25 ms2424 KiB
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define endl '\n' #define all(v) (v).begin(),(v).end() using namespace std; const int N = 100005; int a[N]; int main() { ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } vector <int> difs; for (int i = 2; i <= n; i++) { difs.pb(a[i] - a[i - 1]); } sort(all(difs)); int res = k; for (int i = 0; i < n - k; i++) { res += difs[i]; } cout << res << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...