/**//*
ID: lorelei3
TASK: barn1
LANG: C++
*/
#include <fstream>
#include <algorithm>
using namespace std;
const int MAX = 200;
int a[MAX], b[MAX];
int main(){
int i, j, m, s, c, t;
ifstream in("barn1.in");
ofstream out("barn1.out");
in>>m>>s>>c;
for(i=0; i<c; ++i)
in>>a[i];
sort(a, a+c);
t=a[c-1]-a[0]+1;
for(i=0; i<c-1;++i)
b[i]=a[i+1]-a[i]-1;
sort(b, b+c-1);
for(i=c-2, j=1; i>=0&&j<m; i--,j++)
t-=b[i];
out<<t<<endl;
return 0;
}
posted on 2010-11-09 01:00
小阮 阅读(153)
评论(0) 编辑 收藏 引用 所属分类:
USACO