Problem
Chef has NN slippers, LL 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 XX rupees, what is the maximum amount of rupees that Chef can get for these slippers?
Input Format
The first line contains TT - the number of test cases. Then the test cases follow.
The first line of each test case contains three space-separated integers NN, LL, and XX - 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 100
Example / Sample:
Input:4
0 0 100
10 1 0
1000 10 1000
10 7 1Output:
0
0
10000
3
Explanation
Solution
#include <iostream>
using namespace std;
// Solution from : Code Radius [ https://radiuscode.blogspot.com/ ]
int main() {
int t;
cin>>t;
while(t--) {
int n,l,x;
cin>>n>>l>>x;
if(l>=n-l) {
cout<<(n-l)*x<<endl;
}
else {
cout<<l*x<<endl;
}
}
return 0;
}
Please First Try to Solve Problem by Yourself.