Submission #1777982


Source Code Expand

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
#define eps 1e-7
#define maxi 50005
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 0
Code Size 992 Byte
Status RE
Exec Time 102 ms
Memory 640 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 0 / 400
Status
AC × 3
AC × 4
RE × 9
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 RE 102 ms 640 KB
b06 RE 101 ms 640 KB
b07 RE 101 ms 640 KB
b08 RE 101 ms 640 KB
b09 RE 101 ms 640 KB
b10 RE 101 ms 640 KB
b11 RE 100 ms 640 KB
b12 RE 100 ms 640 KB
b13 RE 101 ms 640 KB