제출 #1286286

#제출 시각아이디문제언어결과실행 시간메모리
1286286juan_alejandroStove (JOI18_stove)C++20
100 / 100
15 ms3008 KiB
#include <bits/stdc++.h> #define endl '\n' #define int long long #pragma GCC optimize("O2") using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(0); cout<<fixed; int n,k; cin>>n>>k; vector<int> x(n); for (int i = 0; i < n; i++) { cin>>x[i]; } vector<int> dp(k); int res=x[n-1]+1-x[0]; //cout<<res<<endl; vector<int> vs; for (int i = 1; i < n; i++) { vs.push_back(x[i]-x[i-1]); } sort(vs.begin(),vs.end()); for (int j = 2; j <= k; j++) { res-=vs.back()-1; vs.pop_back(); } cout<<res<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...