同问啊!我也卡在5、8、9了。兄弟要是你解决了的话能不能告诉一下是什么问题
by bluegod @ 2022-05-23 15:49:01
sort写错了
```cpp
#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);//sort(a+1,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;
}
```
by xrlong @ 2022-07-26 08:03:15