Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Alice has a bucket of water initially having W litres of water in it. The maximum capacity of the bucket is X liters.
Alice turned on the tap and the water starts flowing into the bucket at a rate of Y litres/hour. She left the tap running for exactly Z hours. Determine whether the bucket has been overflown, filled exactly, or is still left unfilled.
For each test case, print the answer on a new line:
overflow
filled
unfilled
You may print each character of the string in uppercase or lowercase (for example, the strings filled
, FIlled
, fiLLed
, and FILLED
will all be treated as identical).
Input: 4
1 2 3 4
10 70 10 6
2 100 4 3
4 3 2 1
Output: overFlow
filled
Unfilled
overflow
Test case 1: Initially the bucket had 1 litre of water, we then added 3 litres of water for 4 hours. Thus, the total bucket inflow was 1+3×4=13 litres. Since this is greater than the capacity of 2 litres, the bucket will OVERFLOW
Test case 2: Initially the bucket had 10 litres of water, we then added 10 litres of water for 6 hours. Thus, the total bucket inflow was 10+10×6=70 litres. Since this is equal to the capacity of 70 litres, the bucket will be FILLED
Test case 3: Initially the bucket had 2 litres of water, we then added 4 litres of water for 3 hours. Thus, the total bucket inflow was 2+4×3=14 litres. Since this is lesser than the capacity of 100 litres, the bucket will be UNFILLED
.
Test case 4: Initially the bucket had 4 litres of water, we then added 2 litres of water for 1 hours. Thus, the total bucket inflow was 4+2×1=6 litres. Since this is more than the capacity of 3 litres, the bucket will OVERFLOW
.
#include <iostream>
using namespace std;
int main() {
int t; cin>>t; while(t--)
{
int w,x,y,z;
cin>>w>>x>>y>>z;
cout<<(x-w==y*z ? "Filled" : (x-w>y*z ? "Unfilled" : "Overflow"))<<endl;
}
return 0;
}
T = int(input())
for i in range(T):
W,X,Y,Z=map(int,input().split())
if W+(Y*Z)==X:
print("filled")
elif W+(Y*Z)>=X:
print("overflow")
elif W+(Y*Z)<=X:
print("unfilled")
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++)
{
int initw=sc.nextInt();
int maxw=sc.nextInt();
int ratew=sc.nextInt();
int hourw=sc.nextInt();
int ans=initw+(ratew*hourw);
if(ans==maxw) System.out.println("Filled");
else if(ans>maxw) System.out.println("Overflow");
else System.out.println("Unfilled");
}
}
}
In our experience, we suggest you solve this Bucket and Water Flow CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Bucket and Water Flow CodeChef Solution
I hope this Bucket and Water Flow CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>