Please Fill out the Feedback Form for Code Radius

Challenge for Most Difficult Problem : CHMDFP032 | Codechef Solution

Problem

In a competition, there are three 33 problems: P, Q, RP,Q,R. Alice challenges Bob that problem RR will be the most difficult, whereas Bob predicts that problem QQ will be the most difficult.

You are given three integers S_P, S_Q, S_RSP​,SQ​,SR​, which represent the number of successful submissions of the problems P, Q, RP,Q,R. Each problem is guaranteed to have a varied amount of submissions. Decide who will win the challenge.
  1. If Alice wins the challenge (that is, if problem RR is the most difficult), then output Alice.
  2. If Bob wins the challenge (that is, if problem QQ is the most difficult), then output Bob.
  3. If no one wins the challenge (since problem PP is the most difficult), output Draw.

Please Share this article...

Input Format

  • The first line of input contains a single integer TT, which represents the number of test cases. The following is a description of TT test cases.
  • Each test case's first and only line comprises three space-separated integers S_P, S_Q, S_RSP​,SQ​,SR​, which represent the number of successful submissions of problems P, Q, RP,Q,R, respectively.

Output Format

For each test case, print the winner of the challenge or the word "Draw" if no one wins the challenge.

Constraints

Sample

Input
3
1 4 2
16 8 10
14 15 9
Output
Draw
Bob
Alice

Explanation

Test case 1: Because problem PP turns out to be the most difficult, no one wins the challenge.
Test case 2: Problem QQ proves to be the most difficult, thus Bob wins the challenge.
Test case 3: Problem RR proves to be the most difficult, thus Alice wins the challenge.

Solution

#include <iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
    int t,a,b,c;
    cin>>t;
    vector<string> ans;
    for(int i=0;i<t;i++){
        cin>>a>>b>>c;
        if(a<b){
            if(a<c) ans.push_back("Draw");
            else ans.push_back("Alice");
        }
        else{
            if(b<c) ans.push_back("Bob");
            else ans.push_back("Alice");
        }
        
    }
    for(int i=0;i<t;i++) cout<<ans[i]<<endl;

    return 0;
}
/* package codechef; // don't place package name! */

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

/* 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
		Scanner s=new Scanner(System.in);
		int t=s.nextInt();
		for(int i=0;i<t;i++){
		    int sa=s.nextInt();
		    int sb=s.nextInt();
		    int sc=s.nextInt();
		    if((sa<sb)&&(sa<sc)){
		        System.out.println("Draw");
		    }
		    else if((sb<sc)&&(sb<sa)){
		        System.out.println("Bob");
		    }
		    else if((sc<sa)&&(sc<sb)){
		         System.out.println("Alice");
		    }
		        
		    }
		    }
		}
	

for _ in range(int(input())):
    a,b,c = map(int, input().split(" "))
    if a<b and a<c :
        print("Draw")
    elif b<a and b<c :
        print("Bob")
    else:
        print("Alice")

Please First Try to Solve Problem by Yourself.

Post a Comment

© Code Radius. All rights reserved. Distributed by Code Rdius Distributed by Pro Templates