Submission #686747

#TimeUsernameProblemLanguageResultExecution timeMemory
686747qweasdzxcStove (JOI18_stove)C++14
100 / 100
26 ms2264 KiB
#include <bits/stdc++.h> #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define vi vector<int> #define vl vector<long long> #define vc vector<char> #define vs vector<string> #define pi pair<int, int> #define pl pair<ll, ll> #define vp vector<pi> #define vpl vector<pl> #define ll long long #define MAX 2147000000 #define MOD 1000000007 using namespace std; int main(){ fastio; int n, k; cin >> n >> k; vi vec(n); for(int i{0}; i < n; ++i){ cin >> vec[i]; } vi A; for(int i{0}; i < n - 1; ++i){ A.push_back(vec[i + 1] - vec[i] - 1); } sort(A.begin(), A.end()); if(k >= n) cout << n; else{ int ans{n}; for(int i{0}; i < n - k; ++i){ ans += A[i]; } cout << ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...