zoukankan      html  css  js  c++  java
  • cf

    #include <iostream>
    #include <algorithm>
    using namespace std;
    /*******************************************************************************************************************
                                     贪心:排序,水过去
    *******************************************************************************************************************/
    #define MAXN 100010
    
    int a[MAXN],s[MAXN];
    
    int main()
    {
        int n,m;
        while(cin>>n>>m)
        {
            for(int i=0; i<n; i++)
                cin>>a[i];
            sort(a, a+n);
            int ans,t,k;
            ans = 0;
            t = k = 0;
            for(int i=1; ; i++){
                if(i == a[k]){k++; continue;}
                if(m >= i){
                    m -= i;
                    s[t++] = i;
                    ans++;
                }
                else break;
            }
            cout<<ans<<endl;
            for(int i=0; i<t; i++){
                if(i == 0)
                    cout<<s[i];
                else
                    cout<<" "<<s[i];
            }
            cout<<endl;
        }
        return 0;
    }
    


  • 相关阅读:
    区别Lua模式匹配中 %a+ 与 .-
    将硬件规定的通信协议用Lua实现(涉及到很多Lua通信的数据转换)
    Lua库-string库
    Unity3d
    Unity3d
    Unity3d
    Unity3d
    Unity3d
    Unity3d
    Unity3d
  • 原文地址:https://www.cnblogs.com/Jstyle-continue/p/6352022.html
Copyright © 2011-2022 走看看