# Correct Slippers: CORRSLP

Correct Slippers Codechef Solution

Codechef Sumbmission link: Click here

## Problem

Chef has N*N* slippers, L*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*X* rupees, what is the maximum amount of rupees that Chef can get for these slippers?

### Input Format

- The first line contains T
*T*– the number of test cases. Then the test cases follow. - The first line of each test case contains three space-separated integers N
*N*, L*L*, and X*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.

### Constraints

- 1 \leq T \leq 10^31≤
*T*≤103 - 0 \leq L \leq N \leq 10^30≤
*L*≤*N*≤103 - 0 \leq X \leq 10^30≤
*X*≤103

### Sample 1:

Input

Output

4 0 0 100 10 1 0 1000 10 1000 10 7 1

0 0 10000 3

### Explanation:

**Test case 11:**Chef has no pairs to sell, so the amount obtained is 00.**Test case 22:**The amount earned by selling a pair is 00, so the total amount obtained is 00.**Test case 33:**Chef can sell 1010 pairs of slippers, each giving 10001000 rupees, so the total amount earned is 1000 \cdot 10 = 100001000⋅10=10000.**Test case 44:**Chef has 1010 slippers of which 77 are left and 33 are right. Therefore Chef can sell a maximum of 33 pairs and in total can get at most 3 \cdot 1 = 33⋅1=3.

## Correct Slippers Codechef Solution in C++

**This code starts from int main so don’t forget to add header files on CodeChef.**

```
int main() {
int t;
cin>>t;
for(int i=0;i< t;i++){
int n,l,x;
cin>>n>>l>>x;
cout<< (min((n-l),l))*x<< endl;
}
return 0;
}
```

## Correct Slippers Codechef Solution in Python

```
# cook your dish here
for t in range(int(input())):
n,l,x = map(int, input().split())
p=0
if(n == 0 or l == 0 or x == 0):
print(0)
elif((n-l)<=l):
p = n-l
print(p*x)
else:
p = l
print(p*x)
```

## Correct 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
{
// your code goes here
try{
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
for(int i=0;i<T;i++){
int n=sc.nextInt();
int l=sc.nextInt();
int x=sc.nextInt();
int r=n-l;
if(r>=l){
System.out.println(l*x);
}
else{
System.out.println(r*x);
}
}
}
catch(Exception e){
System.out.println(e);
}
}
}
```

Correct Slippers Codechef Solution by progies.in

The content uploaded on this website is for reference purposes only. Please do it yourself first. |