求助,#5#8#9调不出了
查看原帖
求助,#5#8#9调不出了
182938
绿豆沙楼主2022/1/23 20:26
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+900;
int a[maxn],b[maxn],m,s,c,tot;
int cmp(int x,int y){
	return x>y;
}
int main(){
	cin>>m>>s>>c;
	for(int i=1;i<=c;i++)cin>>a[i];
	sort(a+c,a+c+1);
	tot=a[c]-a[1]+1;
	for(int i=1;i<=c-1;i++){
		b[i]=a[i+1]-a[i]-1;
	}
	sort(b+1,b+c,cmp);
	for(int i=1;i<=m-1;i++){
		tot=tot-b[i];
	}
	printf("%d\n",tot);
	return 0;
}

2022/1/23 20:26
加载中...