Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Six friends go on a trip and are looking for accommodation. After looking for hours, they find a hotel which offers two types of rooms — double rooms and triple rooms. A double room costs Rs. X, while a triple room costs Rs. Y.
The friends can either get three double rooms or get two triple rooms. Find the minimum amount they will have to pay to accommodate all six of them.
For each testcase, output the minimum amount required to accommodate all the six friends.
Input: 3
10 15
6 8
4 8
Output: 30
16
12
Test case 1: The friends can take three double rooms and thus pay a total of Rs. 30.
Test case 2: The friends can take two triple rooms and thus pay a total of Rs. 16.
Test case 3: The friends can take three double rooms and thus pay a total of Rs. 12
#include <iostream>
using namespace std;
int main() {
int t,x,y;
cin>>t;
while(t--){
cin>>x>>y;
cout<<min((3*x),(2*y))<<endl;
}
return 0;
}
#no. of inputs
t = int(input())
#program
for _ in range(t):
# rates of rooms
x,y= map(int,input().split())
a = x*3
b = y*2
if a <= b:
print(a)
else:
print(b)
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();
while(t-- > 0){
int x = sc.nextInt();
int y = sc.nextInt();
int db = x * 3 ;
int tr = y * 2 ;
if(db >= tr){
System.out.println(tr);
}
else {
System.out.println(db);
}
}
}
}
In our experience, we suggest you solve this Six Friends 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 Six Friends CodeChef Solution
I hope this Six Friends 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 >>