Mahasena Codechef Solution|Problem Code:AMR15A

Mahasena  Codechef Solution

Problem

Kattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as Mahasena.

Kattapa was known to be a very superstitious person. He believed that a soldier is “lucky” if the soldier is holding an even number of weapons, and “unlucky” otherwise. He considered the army as “READY FOR BATTLE” if the count of “lucky” soldiers is strictly greater than the count of “unlucky” soldiers, and “NOT READY” otherwise.

Given the number of weapons each soldier is holding, your task is to determine whether the army formed by all these soldiers is “READY FOR BATTLE” or “NOT READY”.

Note: You can find the definition of an even number here.

Input

The first line of input consists of a single integer N denoting the number of soldiers. The second line of input consists of N space separated integers A1A2, …, AN, where Ai denotes the number of weapons that the ith soldier is holding.

Output

Generate one line output saying “READY FOR BATTLE”, if the army satisfies the conditions that Kattapa requires or “NOT READY” otherwise (quotes for clarity).

Constraints

  • 1 ≤ N ≤ 100
  • 1 ≤ Ai ≤ 100

Sample Input 1 

1
1

Sample Output 1 

NOT READY

Mahasena – CodeChef Solution in JAVA

import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextInt();
		}
		System.out.println(solve(A) ? "READY FOR BATTLE" : "NOT READY");
		sc.close();
	}
	static boolean solve(int[] A) {
		return Arrays.stream(A).filter(x -> x % 2 == 0).count() > Arrays.stream(A).filter(x -> x % 2 != 0).count();
	}
}

Disclaimer: The above Problem ( Mahasena ) is generated by CodeChef but the solution is provided by  Chase2learn.This tutorial is only for Educational and Learning purpose.

Leave a Comment