title link : Http://codeforces.com/problemset/problem/659/C
Test Instructions :
N is an already existing number, M is the maximum number available and
Asked to choose the numbers that they did not have, and the numbers of those numbers could not exceed m
and require the number of optional numbers the more the better
Output an Answer
Problem Solving Ideas :
Just started to open a bool type of 1e9 array, and then judge can
But hand it over to find out the memory limit
The 1e9 array is then converted to an array of 2*1e6.
Specific reasons should be considered from mathematical figures and aspects
The specific code is as follows :
#include <bits/stdc++.h>using namespacestd;BOOLa[200006];intMain () {intn,m,t; scanf ("%d%d",&n,&m); for(intI=0; i<n;i++) {cin>>T; if(t>200000)Continue; A[t]=1; } intKind=0; inti; for(i=1; i<=200000; i++) { if(M<i) Break; if(a[i]==0) {m-=i; Kind++; }} printf ("%d\n", kind); for(intj=1; j<i;j++) { if(!A[j]) printf ("%d", J); } printf ("\ n"); return 0;}
Codeforces 659C Tanya and Toys