304 North Cardinal St.
Dorchester Center, MA 02124

# Chef and Pairing Slippers CodeChef Solution

## Problem – Chef and Pairing Slippers CodeChef Solution

Chef has N slippers, L of which are left slippers and the rest are right slippers. Slippers must always be sold in pairs, where each pair contains one left and one right slipper. If each pair of slippers cost X rupees, what is the maximum amount of rupees that Chef can get for these slippers?

### Input Format

• The first line contains T – the number of test cases. Then the test cases follow.
• The first line of each test case contains three space-separated integers NL, and X – the total number of slippers, the number of left slippers, and the price of a pair of slippers in rupees.

### Output Format

For each test case, output on one line the maximum amount of rupees that Chef can get by selling the slippers that are available.

• 1≤T≤10^3
• 0≤LN≤10^3
• 0≤X≤10^3

### Sample 1:

``````Input:
4
0 0 100
10 1 0
1000 10 1000
10 7 1
Output:
0
0
10000
3
``````

### Explanation:

• Test case 1: Chef has no pairs to sell, so the amount obtained is 0.
• Test case 2: The amount earned by selling a pair is 0, so the total amount obtained is 0.
• Test case 3: Chef can sell 10 pairs of slippers, each giving 1000 rupees, so the total amount earned is 1000⋅10=10000.
• Test case 4: Chef has 10 slippers of which 7 are left and 3 are right. Therefore Chef can sell a maximum of 3 pairs and in total can get at most 3⋅1=3.

## Chef and Pairing Slippers CodeChef Solution in C++14

``````#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define endl "\n"
int main() {
fast
int t;cin>>t;
while(t--)
{
int n,l,x;cin>>n>>l>>x;
cout<<x*min(l,n-l)<<'\n';
}
return 0;
}
``````

## Chef and Pairing Slippers CodeChef Solution in Pyth 3

``````# cook your dish here
for _ in range(int(input())):
x,y,z = map(int,input().split());
b = min(x-y,y)
print(b*z)``````

## Chef and Pairing Slippers CodeChef Solution in Java

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
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 n = sc.nextInt();
int l = sc.nextInt();
int x = sc.nextInt();
System.out.println(x*Math.min(l,n-l));

}
}
}
``````
##### Chef and Pairing Slippers CodeChef Solution Review:

In our experience, we suggest you solve this Chef and Pairing Slippers 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 Chef and Pairing Slippers CodeChef Solution

Find on CodeChef

##### Conclusion:

I hope this Chef and Pairing Slippers 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