Submission #998233

#TimeUsernameProblemLanguageResultExecution timeMemory
998233ihneStove (JOI18_stove)C++17
100 / 100
19 ms2908 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pii pair<int,int> #define pb push_back #define xdd cout<<"HAHA"<<endl; #define bug1(xd) cout<<xd<<endl; #define bug2(xd,xd1) cout<<xd<<" "<<xd1<<endl; #define bug3(xd,xd1,xd2) cout<<xd<<" "<<xd1<<" "<<xd2<<endl; #define bug4(xd,xd1,xd2,xd3) cout<<xd<<" "<<xd1<<" "<<xd2<<" "<<xd3<<endl; #define bug5(xd,xd1,xd2,xd3,xd4) cout<<xd<<" "<<xd1<<" "<<xd2<<" "<<xd3<<" "<<xd4<<endl; #define bug6(xd,xd1,xd2,xd3,xd4,xd5) cout<<xd<<" "<<xd1<<" "<<xd2<<" "<<xd3<<" "<<xd4<<" "<<xd5<<endl; #define bug7(xd,xd1,xd2,xd3,xd4,xd5,xd6) cout<<xd<<" "<<xd1<<" "<<xd2<<" "<<xd3<<" "<<xd4<<" "<<xd5<<" "<<xd6<<endl; const int mn=1e5+5; const int mod=1e9+7; int a[mn]; vector<int> v; signed main(){ //freopen("","r",stdin); //freopen("","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); int n,k; cin>>n>>k; for (int i=1;i<=n;i++){ cin>>a[i]; if (i!=1) v.pb(a[i]-a[i-1]-1); } int ans=a[n]-a[1]+1; sort(v.begin(),v.end(),greater<int>()); for (int i=0;i<k-1;i++){ ans-=v[i]; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...