标签:
#include <algorithm>
#include <cstdio>
using namespace std;
int a[100000 + 10];
int ans[1000000];
int main(){
int n,m;
scanf("%d%d",&n,&m);
for(int i = 0;i < n ; ++i){
scanf("%d",&a[i]);
}
a[n] = 0;
a[n + 1] = 1E9 + 10;
sort(a,a+n+2);
int cnt = 0;
for(int i = 0;i < n+2 && m > 0; ++i){
for(int j = a[i] + 1;j < a[i + 1] && m > 0;++j){
m -= j;
if(m < 0) break;
ans[cnt++] = j;
}
}
printf("%d\n",cnt);
for(int i = 0;i < cnt;++i){
printf("%d ",ans[i]);
}
printf("\n");
return 0;
}
[2016-03-31][codeforces][659C][Tanya and Toys]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/fe15817bf036440bf286fe099bc860b6.html