Submission #1087041

#TimeUsernameProblemLanguageResultExecution timeMemory
1087041MahmytMStove (JOI18_stove)C++17
100 / 100
15 ms2208 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define yes cout<<"YES"<<endl #define no cout<<"NO"<<endl void afterdot(int n){ cout<<setprecision(n)<<fixed; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n,m; cin>>n>>m; int a[n+2]; for(int i=1;i<=n;i++){ cin>>a[i]; } int b[n+2]; for(int i=1;i<n;i++){ b[i]=a[i+1]-a[i]; } sort(b+1,b+n); int ans=0; for(int i=1;i<=n-m;i++){ ans+=b[i]; } ans+=(m); cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...