Chef and Paper Solution

Problem

Chef has to give a test which has a total of N question, each question carries 3 marks for a correct answer and -1 for an incorrect answer. Chef decided to attempt all the questions. It is known that Chef got X questions correct and the rest of them incorrect. For Chef to pass the course he must score at least P marks.

Will Chef be able to pass the exam or not?

Input Format

  • First line will contain T, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, three integers N, X, P.

Output Format

For each test case output "PASS" if Chef passes the exam and "FAIL" if Chef fails the exam.

You may print each character of the string in uppercase or lowercase (for example, the strings "pAas", "pass", "Pass" and "PASS" will all be treated as identical).

Constraints

  • 1 \leq T \leq 1000
  • 1 \leq N \leq 100
  • 0 \leq X \leq N
  • 0 \leq P \leq 3\cdot N

Sample 1:

Input
Output
3
5 2 3
5 2 4
4 0 0
PASS
FAIL
FAIL

Explanation:

Test case 1: Chef gets 2 questions correct giving him 6 marks and since he got 3 questions incorrect so he faces a penalty of -3. So Chef's final score is 3 and the passing marks are also 3, so he passes the exam :)

Test case 2: Chef's total marks are 3 and since the passing marks are 4, Chef fails the test :(

Test case 3: Chef got all the problems wrong and thus his total score is -4. Since the passing marks are 0, Chef fails the exam :(






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

int n,x,p,t,a,b;

        Scanner sc=new Scanner(System.in);

        t=sc.nextInt();

        while(t-->0){

            n=sc.nextInt();

            x=sc.nextInt();

            p=sc.nextInt();

            a=3*x;

            b=(n-x)*(-1);

            if(a+b>=p)

                System.out.println("PASS");

            else

                System.out.println("FAIL");

        }

}

}


Post a Comment

0 Comments