Bucket and Water Flow solution codechef

Bucket and Water Flow solution codechef

Alice has a bucket of water initially having WW litres of water in it. The maximum capacity of the bucket is XX liters.

Alice turned on the tap and the water starts flowing into the bucket at a rate of YY litres/hour. She left the tap running for exactly ZZ hours. Determine whether the bucket has been overflown, filled exactly, or is still left unfilled.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases. The description of the test cases follows.
  • Each test case consists of a single line of input containing four space-separated integers W, X, Y, ZW, X, Y, Z.

Output Format

Bucket and Water Flow solution codechef

For each test case, print the answer on a new line:

  • If the bucket has overflown print overflow
  • If it is exactly filled print filled
  • If it is still unfilled, print unfilled

You may print each character of the string in uppercase or lowercase (for example, the strings filledFIlledfiLLed, and FILLED will all be treated as identical).

To submit a solution choose problem from list of problems and press button ‘Submit’ near the top right corner of the problem page. You can submit multiple solutions to each problem. Score for the problem is equal to the score of the best submitted solution.

To see the Statistic for problem choose problem from list of problems and press button ‘All submissions’ at the top of the problem description. To view the status, hover over the check box, cross or warning icon in the result column.


  • 1T10001≤T≤1000
  • 1W,X,Y,Z10001≤W,X,Y,Z≤1000


Bucket and Water Flow solution codechef

  • Subtask 1 (100 points):
    • Original constraints.

Sample Input 1 

1 2 3 4 
10 70 10 6 
2 100 4 3 

Sample Output 1 



Bucket and Water Flow solution codechef

Test case 11: Initially the bucket had 11 litre of water, we then added 33 litres of water for 44 hours. Thus, the total bucket inflow was 1+3×4=131+3×4=13 litres. Since this is greater than the capacity of 44 litres, the bucket will OVERFLOW

Test case 22: Initially the bucket had 1010 litres of water, we then added 1010 litres of water for 66 hours. Thus, the total bucket inflow was 10+10×6=7010+10×6=70 litres. Since this is equal to the capacity of 7070 litres, the bucket will be FILLED

Test case 33: Initially the bucket had 22 litres of water, we then added 44 litres of water for 33 hours. Thus, the total bucket inflow was 2+4×3=142+4×3=14 litres. Since this is lesser than the capacity of 100100 litres, the bucket will be UNFILLED.


Click here

Leave a Comment

Your email address will not be published.