Submission #1777985


Source Code Expand

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
#define eps 1e-7
#define maxi 100005
long long  h[maxi];
long long hi[maxi];
long long  n,a,b;
long long in=10000000000;
bool C(long long  x){
    long long t=x;
    for(long long i=0;i<n;i++)
        hi[i]=h[i];
    for(long long i=0;i<n;i++){
        hi[i]-=x*b;
        if(hi[i]<=0) continue;
        long long y;
        if(hi[i]%(a-b)==0)
          y=hi[i]/(a-b);
        else
            y=hi[i]/(a-b)+1;
        t-=y;
    }
    if(t>=0) return true;
    return false;
}
void solve(){
    sort(h,h+n);
long long  lb=0,ub=in;
   while(ub-lb>1){
        long long mid=(lb+ub)/2;
        //cout<<mid<<" "<<C(mid)<<" "<<ub<<endl;
        if(C(mid)) ub=mid;
        else  lb=mid;
        //cout<<lb<<" "<<ub<<endl;
    }
    cout<<ub<<endl;
}
int main()
{
           scanf("%d%d%d",&n,&a,&b);
   for(int i=0;i<n;i++)  scanf("%d",&h[i]);
  solve();
   return 0;
}

Submission Info

Submission Time
Task D - Widespread
User vjudge3
Language C++14 (GCC 5.4.1)
Score 400
Code Size 993 Byte
Status AC
Exec Time 45 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:45:35: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
            scanf("%d%d%d",&n,&a,&b);
                                   ^
./Main.cpp:45:35: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat=]
./Main.cpp:45:35: warning: format ‘%d’ expects argument of type ‘int*’, but argument 4 has type ‘long long int*’ [-Wformat=]
./Main.cpp:46:42: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
    for(int i=0;i<n;i++)  scanf("%d",&h[i]);
                                          ^
./Main.cpp:45:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
            scanf("%d%d%d",&n,&a,&b);
                                    ^
./Main.cpp:46:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attri...

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 13
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 20 ms 1792 KB
b06 AC 44 ms 1792 KB
b07 AC 30 ms 1792 KB
b08 AC 31 ms 1792 KB
b09 AC 25 ms 1792 KB
b10 AC 25 ms 1792 KB
b11 AC 25 ms 1792 KB
b12 AC 26 ms 1792 KB
b13 AC 45 ms 1792 KB