Correct Logic But Giving Wrong Answer Please Help! |Air Blimp

Problem Link :-


void solve()
  {

    int t ; cin>>t; 
    
    while(t--)
    {
      
      ll n,x,y; 
      cin>>n>>x>>y; 

      vector<ll> v(n) ; 

      for(int c =0 ;c<n;c++)
        cin>>v[c];
     

      ll max = -1  ;

      for(auto c : v)
      {
        if(c>max)
          max =c ;
      } 

      if(x<=y)
      {
        double y1 = y , max1 = max ;
        cout<<ceil(max1/y1)<<endl;


      }
      else 
      {
        ll sum = 0 ; 
        ll count = 0 ; 
        for(int d = v.size()-1;d>=0;d--)
        {
           
           double p = x ;
           double curr = v[d] - sum ; 
           if(curr>0){

            ll co = ceil(curr/p);

            sum += x*co; 

            count+=co;

           }
          

        }

        cout<<count<<endl;

      }




    }

  }


In this case, the sadness of cities 1, 2, …, i-1 will decrease by Y, the sadness of city i will decrease by X

you don’t use Y on your logic. You decrease all values by X.

1 Like

Thanks a lot I got it . :grinning: :heartpulse:

Thanks Sir. I solved it . :innocent:

1 Like