PASSORFAIL: PASS OR FAIL

                     

Problem Link: https://www.codechef.com/CU1PP0005/problems/PASSORFAIL

Problem code: PASSORFAIL

Chef is struggling to pass a certain college course.

The test has a total of NN question, each question carries 33 marks for a correct answer and −1−1 for an incorrect answer. Chef is a risk-averse person so he decided to attempt all the questions. It is known that Chef got XX questions correct and the rest of them incorrect. For Chef to pass the course he must score at least PP marks.

Will Chef be able to pass the exam or not?

Solution:

#include <iostream>
using namespace std;

int main() {
  // your code goes here
  int t;
  cin>>t;
  while(t--)
  {
      int n , x, p;
      cin>>n>>x>>p;
      int correctMarks = x*3;
      int incorrectMarks = (n-x)*(-1);
      int total = correctMarks + incorrectMarks;
       if (total>=p){
           cout<<"PASS"<<endl;
       }
       else
         cout<<"FAIL"<<endl;
  }
  cout<<endl;
  
}