zoukankan      html  css  js  c++  java
  • AtCoder Regular Contest 075 D Widespread

    题目传送门

    这道题其实二分一下答案就okay了的 不过LL什么的有时候忘了加 被卡了下

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define LL long long
    using namespace std;
    const int M=100007;
    int read(){
        int ans=0,f=1,c=getchar();
        while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
        while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
        return ans*f;
    }
    int n,p,q,w;
    int s[M];
    LL ans;
    bool check(LL x){
        LL now=x*q,tot=0;
        int top=n,v;
        while(top){
            if(s[top]<=now) break;
            if((s[top]-now)%w) v=(s[top]-now)/w+1;
            else v=(s[top]-now)/w;
            tot+=v;
            top--; 
        }
        return tot<=x;
    }
    int main()
    {
        n=read(); p=read(); q=read(); w=p-q;
        for(int i=1;i<=n;i++) s[i]=read();
        sort(s+1,s+1+n);
        LL l=0,r=1e9;
        while(l<=r){
            LL mid=(l+r)>>1;
            if(check(mid)) ans=mid,r=mid-1;
            else l=mid+1;
        }
        printf("%lld
    ",ans);
        return 0;
    }
    View Code
  • 相关阅读:
    何为 ISAPI
    MacDown-The open source Markdown editor for OS X.
    Atom使用
    运维
    Perl
    Kaggle
    J2EE
    leetcode
    Tensorflow 学习笔记
    EXCEL公式及宏
  • 原文地址:https://www.cnblogs.com/lyzuikeai/p/7073535.html
Copyright © 2011-2022 走看看