Submission #2242973


Source Code Expand

#include <iostream>
#include <math.h>

int tamesi(long long n,long long a,long long b,long long h[],long long ans);

int main(){
  
  long long n,a,b;
 
  scanf("%lld%lld%lld",&n,&a,&b);
  
  long long h[n];
  
  for(int i=0;i<n;i++){
    scanf("%lld",&h[i]);
  }
 
  long long ans=0;

  while(tamesi(n,a,b,h,ans)==0){
    ans+=100000000;
  }
  ans-=100000000;
  while(tamesi(n,a,b,h,ans)==0){
    ans+=10000000;
  }
  ans-=10000000;
  while(tamesi(n,a,b,h,ans)==0){
    ans+=1000000;
  }
  ans-=1000000;
  while(tamesi(n,a,b,h,ans)==0){
    ans+=100000;
  }
  ans-=100000;
  while(tamesi(n,a,b,h,ans)==0){
    ans+=10000;
  }
  ans-=10000;

  while(tamesi(n,a,b,h,ans)==0){
    ans+=1000;
  }
  ans-=1000;
  while(tamesi(n,a,b,h,ans)==0){
    ans+=100;
  }
  ans-=100;

   while(tamesi(n,a,b,h,ans)==0){
    ans+=10;
  }
  ans-=10;

   while(tamesi(n,a,b,h,ans)==0){
    ans+=1;
  }
 

  printf("%lld\n",ans);

  
  
  return 0;
}

int tamesi(long long n,long long a,long long b,long long h[],long long ans){
  long long kari=0;
  long long z[n];
  
  for(long long i=0;i<n;i++){
    z[i]=h[i];
    z[i]=z[i]-ans*b;
    if(z[i]<=0){z[i]=0;}
    kari+=ceil(z[i]*1.0/(a-b)*1.0);
      }
 
  if(kari<=ans){return 1;}
  else{return 0;}
}

  

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld",&n,&a,&b);
                                 ^
./Main.cpp:15:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&h[i]);
                        ^

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 21 ms 1792 KB
b06 AC 38 ms 1792 KB
b07 AC 41 ms 1792 KB
b08 AC 42 ms 1792 KB
b09 AC 47 ms 1792 KB
b10 AC 36 ms 1792 KB
b11 AC 35 ms 1792 KB
b12 AC 31 ms 1792 KB
b13 AC 31 ms 1792 KB