제출 #536133

#제출 시각아이디문제언어결과실행 시간메모리
536133Blnkhole224Stove (JOI18_stove)C++17
20 / 100
2 ms488 KiB
#include <bits/stdc++.h>
#define fori(i,a,b) for(long i=a;i<=b;i++)
using namespace std;
typedef long long ll;
ll const N=2e3+10;
ll a[N],b[N];
ll n,d,res,k;
void speed()
{    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main()
{
   speed();
   cin >> n >> k;
   k=k-1;
   fori(i,1,n)
   {
       cin >> a[i];
   }
   fori(i,2,n)
   {
       b[i]=a[i]-a[i-1];
   }
   res=a[n]-a[1]+1;
   sort(b+1,b+n+1,greater<int>());
   for(long i=1;i<=k;i++)
   {
       res-=b[i]-1;
   }
   cout << res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...