Submission #1033635

#TimeUsernameProblemLanguageResultExecution timeMemory
1033635reginoxStove (JOI18_stove)C++17
100 / 100
18 ms992 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k, x, p; vector<int> v; cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> x; if(i > 1) v.push_back(x - p - 1); p = x; } sort(v.begin(), v.end()); int res = n; for(int i = 0; i < n-k; i++) res += v[i]; cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...