제출 #1290422

#제출 시각아이디문제언어결과실행 시간메모리
1290422keremStove (JOI18_stove)C++20
100 / 100
14 ms1488 KiB
#include <bits/stdc++.h> using namespace std; //~ #define int long long #define pb push_back #define emb emplace_back #define fr first #define sc second #define all(x) x.begin(),x.end() #define sp << " " << #define N 100000 #define inf (int)1e9 typedef pair<int,int> ii; typedef tuple<int,int,int> iii; void solve(){ int n,k; cin >> n >> k; int a[n]; vector<int> v; for(int i=0;i<n;i++){ cin >> a[i]; if(i) v.pb(a[i]-a[i-1]-1); } int ans=a[n-1]-a[0]+1; sort(all(v),greater<int>()); for(int i=0;i<k-1;i++) ans-=v[i]; cout << ans << "\n"; } int32_t main(){ //~ freopen("hopscotch.in","r",stdin); //~ freopen("hopscotch.out","w",stdout); cout << fixed << setprecision(0); ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); int test=1; //~ cin >> test; while(test--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...