zoukankan      html  css  js  c++  java
  • CodeForces

    CodeForces - 682B 

    Input

    The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of elements in the Alyona's array.

    The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the array.

    Output

    Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.

    求更改后数列中没有的最小整数,不知更改,只能求最大可能

    构成1 2 3 4.。

    对于5 6 7  1 2 3  

    #include "cstdio"
    #include "iostream"
    #include "string"
    #include "cstring"
    #include "cmath"
    #include "vector"
    #include "map"
    #include "algorithm"
    using namespace std;
    int a[100005];
    int main()
    {
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            for(int i=0;i<n;i++)
            {
                scanf("%d",&a[i]);
            }
            sort(a,a+n);
            int min1=0;
            for(int i=0;i<n;i++)
                if(a[i]>min1)//可改
                    ++min1;///最大可能+1
            printf("%d
    ",min1+1);
        }
    }

     

  • 相关阅读:
    9.17考试
    Something
    tesuto-Mobius
    7.22考试
    填坑...P1546 最短网络 Agri-Net
    P1125 笨小猴
    P2822 组合数问题
    致我们曾经刷过的水题
    Luogu P1186 玛丽卡
    Luogu P1726 上白泽慧音
  • 原文地址:https://www.cnblogs.com/kimsimple/p/6706849.html
Copyright © 2011-2022 走看看