439 D. Devu and his Brother

/*
 简单三分法解决,也可以排序后简单贪心.
 */
#include 
#include 
#include 
using namespace std;
const int maxn = 100000 + 100;
#define LL long long
int n,m;
LL a[maxn],b[maxn];
bool cmp(int a,int b)
{
    return a>b;
}
LL F(LL v)
{
    LL cnt=0;
    for(int i=0;i=v) break;
        else
        {
            cnt+=v-a[i];
        }
    }
    for(int i=0;i=b[0])
    {
        printf("0\n");
        return 0;
    }
    l=a[0],r=b[0];
    LL ans=0;
    while(1)
    {
        if(r-l<=10)
        {
            ans=l;
            for(LL i=l+1;i<=r;++i)
            {
                if(F(i)

你可能感兴趣的:(codeforces)