Codeforces 659C Tanya and Toys

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.