GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 3 August 2022

[Solution] Air Blimp CodeChef Solution



Problem

There are N cities in a row. The i-th city from the left has a sadness of A_i.

In an attempt to reduce the sadness of the cities, you can send blimps from the left of city 1 that move rightwards (i.e, a blimp crosses cities 1, 2, \ldots in order)

You are given two integers X and Y. For each blimp sent, you can make one of the following choices:

  • Let the blimp fly over every city, in which case the sadness of every city will decrease by Y, or,
  • Choose a city i (1 \leq i \leq N), and shower confetti over city i. In this case, the sadness of cities 1, 2, \ldots, i-1 will decrease by Y, the sadness of city i will decrease by X, and cities i+1, \ldots, N see no change in sadness.

Find the minimum number of blimps needed such that, by making the above choice optimally for each blimp, you can ensure that no city is sad (i.e, in the end every city has sadness \leq 0).

Input Format

  • The first line of input contains a single integer T — the number of test cases. Then the test cases follow.
  • The first line of each test case contains three space-separated integers N, X, Y — the size of the array, and the parameters mentioned in the statement.
  • The second line of each test case contains N space-separated integers A_1, A_2, \ldots, A_N, denoting the sadness of the N cities.

Output Format

For each test case, output on a new line the minimum number of blimps needed such that no city is sad.

No comments:

Post a Comment