Dominant Army CodeChef Solution

Problem – Dominant Army CodeChef Solution

In the medieval age, there were 3 kingdoms AB, and C. The army of these kingdom had NA​, NB​, and NC​soldiers respectively.

You are given that an army with X soldiers can defeat an army with Y soldiers only if X>Y.

An army is said to be dominant if it can defeat both the other armies combined. For example, kingdom C‘s army will be dominant only if NC​>NA​+NB​.

Determine whether any of the armies is dominant or not.

Input Format

  • The first line contains a single integer T – the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains three integers NA​, NB​, and NC​ – the number of warriors in the armies of kingdoms AB, and C respectively.

Output Format

For each test case, output YES if any of the armies is dominant. Otherwise, output NO.

You may print each character of YES and NO in uppercase or lowercase (for example, yesyEsYes will be considered identical).

Constraints

  • 1≤T≤1000
  • 1≤NA​,NB​,NC​≤100

Sample 1:

Input: 4
15 5 6
12 13 16
1 1 100
10 10 20
Output: YES
NO
YES
NO

Explanation:

Test case 1: The kingdom A‘s army is dominant since 15>5+6.

Test case 2: We can observe that none of the armies is dominant.

Test case 3: The kingdom C‘s army is dominant since 100>1+1.

Test case 4: We can observe that none of the armies is dominant. Note that the kingdom C‘s army is not dominant since 20≤10+10.

Dominant Army CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
    int t; cin>>t; while(t--)
    {
        int a,b,c;
        cin>>a>>b>>c;
        cout<<(a>b+c || b>a+c || c>a+b ? "YES" : "NO")<<endl;
    }
	return 0;
}

Dominant Army CodeChef Solution in Pyth 3

T = int(input())
for i in range(T):
    A,B,C=map(int,input().split())
    if A>(B+C) or B>(C+A) or C>(A+B):
        print("YES")
    else:
        print("NO")
    

Dominant Army CodeChef 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();
	while(t-- >0)
	{
	    int x=sc.nextInt();
	    int y=sc.nextInt();
	    int z=sc.nextInt();
	    if(x>(y+z)) System.out.println("YES");
	    else if(y>(x+z)) System.out.println("YES");
	    else if(z>(x+y)) System.out.println("YES");
	    else System.out.println("NO");
	}
	}
}
Dominant Army CodeChef Solution Review:

In our experience, we suggest you solve this Dominant Army CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Dominant Army CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Dominant Army CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *