Bidding Auction Solution Codechef

Bidding Auction Solution Codechef

Alice, Bob and Charlie are bidding for an artifact at an auction. Alice bids A rupees, Bob bids B rupees, and Charlie bids C rupees (where A, B, and C are distinct). According to the rules of the auction, the person who bids the highest amount will win the auction. Determine who will win the auction.

Input Format

  • The first line contains a single integer TT — the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains three integers A, B, and C, the amount bid by Alice, Bob, and Charlie respectively.

Output Format

  • For each test case, output who (out of Alice, Bob, and Charlie) will win the auction.
  • You may print each character of Alice, Bob, and Charlie in uppercase or lowercase (for example, ALICE, aliCe, aLIcE will be considered identical).

Constraints

  • 1≤T≤1000
  • 1≤A,B,C≤1000
  • A, B, and C are distinct.

Sample Input 1

4
200 100 400
155 1000 566
736 234 470
124 67 2

Sample Output 1

Charlie
Bob
Alice
Alice

Explanation

  • Test Case 1: Charlie wins the auction since he bid the highest amount.
  • Test Case 2: Bob wins the auction since he bid the highest amount.
  • Test Case 3: Alice wins the auction since she bid the highest amount.
  • Test Case 4: Alice wins the auction since she bid the highest amount.

SOLUTION

Program: Bidding Auction Solution in Python

for _ in range(int(input())):
    a=list(map(int,input().split()))
    if a[0]>a[1] and a[0]>a[2]:
        print('Alice')
    elif a[1]>a[0] and a[1]>a[2]:
        print('Bob')
    else:
        print('Charlie')

Program: Bidding Auction Solution in C++

#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
	int t;
	cin>>t;
	while(t--){
	    int a,b,c;
	    cin>>a>>b>>c;    
	    int res=max(a,max(b,c));
	    if(res==a){
	        cout<<"Alice"<<endl;
	    }
	    else if(res==b){
	        cout<<"Bob"<<endl;
	    }
	    else{
	        cout<<"Charlie"<<endl;
	    }
	}
	return 0;
}

Program: Bidding Auction 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();
		for(int i = 0; i < t; i++)
		{
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    if(a > b){
		        if(a > c)
		            System.out.println("Alice");
		        else
		            System.out.println("Charlie");
		    }
		    else{
		        if(b > c)
		            System.out.println("Bob");
		        else
		            System.out.println("Charlie");
		    }
		}
	}
}

Related:

Leave a Comment

three × 4 =