Codechef•May 13, 2025
Chef and Water Bottles
Hazrat Ali
Codechef
There is a water tank in Chefland having KK litres of water. Chef wants to fill the empty bottles using the water in the tank.
Assuming that Chef does not spill any water while filling the bottles, find out the maximum number of bottles Chef can fill completely.
Input Format
- First line will contain TT, number of test cases. Then the test cases follow.
- Each test case contains of a single line of input, three integers N,X,N,X, and KK.
Output Format
For each test case, output in a single line answer, the maximum number of bottles Chef can fill completely.
Constraints
- 1≤T≤100
- 1≤N,X≤105
- 0≤K≤105
Sample 1:
Input
3 5 2 8 10 5 4 3 1 4
Output
4 0 3
Solution
#include <stdio.h>
int main(void) {
int m,sum=0;
scanf("%d",&m);
while(m--){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
sum = c/b;
if(sum >= a){
printf("%d\n",a);
}
else printf("%d\n",sum);
}
return 0;
}