Codeforces Round #562 (Div. 2) / Codeforces 1169 C. Increasing by Modulo

 题目链接:https://codeforces.com/contest/1169/problem/C

水题,二分答案即可。

#include
using namespace std;
int a[300005];
int n,m;
int solve(int x)
{
    int maxx=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]x)
                maxx=a[i];
        }
    }
    return 1;
}
int main()
{
    int i,j,k,ans,num,sum;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int l=0,r=m;
    while(l>1;
        if(solve(mid))
        {
            ans=mid;
            r=mid;
        }
        else
            l=mid+1;
    }
    printf("%d\n",l);
    return 0;
}

 

你可能感兴趣的:(codeforces)