提交时间:2023-12-12 16:28:13
运行 ID: 115645
#include <bits/stdc++.h> using namespace std; const int N=20000+10,INF=0x3f3f3f3f; int m,s,c,a[N],jian_ge[N]; 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+1,a+c+1); for(int i=1;i<=c-1;i++) jian_ge[i]=a[i+1]-a[i]-1; sort(jian_ge+1,jian_ge+c,cmp); int maxx=a[c]-a[1]+1; for(int i=1;i<=m-1;i++) maxx-=jian_ge[i]; cout<<maxx; return 0; }