Six Friends CodeChef Solution

Problem – Six Friends CodeChef Solution

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.

Input Format

  • The first line contains a single integer T – the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains two integers X and Y – the cost of a double room and the cost of a triple room.

Output Format

For each testcase, output the minimum amount required to accommodate all the six friends.

Constraints

  • 1≤T≤100
  • 1≤X<Y≤100

Sample 1:

Input: 3
10 15
6 8
4 8
Output: 30
16
12

Explanation:

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

Six Friends CodeChef Solution in C++17

#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;
}

Six Friends CodeChef Solution in Pyth 3

#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)

Six Friends CodeChef Solution in Java

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);
		    }
		    
		}
	}
}
Six Friends CodeChef Solution Review:

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

Find on CodeChef

Conclusion:

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 >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published.