Challenge for Most Difficult Problem Solution

Problem

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

You are given three integers S_P, S_Q, S_R, which represent the number of successful submissions of the problems P, 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 R is the most difficult), then output Alice.

  2. If Bob wins the challenge (that is, if problem Q is the most difficult), then output Bob.

  3. If no one wins the challenge (since problem P is the most difficult), output Draw.

Note: The problem with the fewest successful submissions is the most difficult.

Input Format

  • The first line of input contains a single integer T, which represents the number of test cases. The following is a description of T test cases.
  • Each test case's first and only line comprises three space-separated integers S_P, S_Q, S_R, which represent the number of successful submissions of problems P, 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

  • 1 \leq T \leq 100
  • 1 \leq S_P,S_Q,S_R \leq 100
  • S_P, S_Q, S_R are all distinct.

Sample 1:

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

Explanation:

Test case 1: Because problem P turns out to be the most difficult, no one wins the challenge.

Test case 2: Problem Q proves to be the most difficult, thus Bob wins the challenge.

Test case 3: Problem R proves to be the most difficult, thus Alice wins the challenge.





Program :


 /* 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

Scanner sc=new Scanner (System.in);

int t=sc.nextInt();

while(t-->0)

{

    int p=sc.nextInt();

    int q=sc.nextInt();

    int r=sc.nextInt();

    if(p<q && p<r)

    {

        System.out.println("Draw");

    }

    if(q<p && q<r)

    {

        System.out.println("Bob");

    }

    if(r<p && r<q)

    {

        System.out.println("Alice");

    }

}

}

}


Post a Comment

0 Comments