Codechef•Sep 08, 2025
Six Friends
Hazrat Ali
Codechef
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
Solution
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int x, y;
cin >> x >> y;
int s = x * 3;
int z = y * 2;
cout << min(s, z) << endl;
}
return 0;
}