이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |