Mark the Answer

QUESTION

Our friend Monk has an exam that has quite weird rules. Each question has a difficulty level in the form of an Integer. Now, Monk can only solve the problems that have difficulty level less than X . Now the rules are-\n\nScore of the student is equal to the maximum number of answers he/she has attempted without skipping a question.\nStudent is allowed to skip just \”one\” question that will not be counted in the continuity of the questions.\nNote- Assume the student knows the solution to the problem he/she attempts and always starts the paper from first question.\n\nGiven the number of Questions, N ,the maximum difficulty level of the problem Monk can solve , X ,and the difficulty level of each question , Ai can you help him determine his maximum score?\n\nInput Format\nFirst Line contains Integer \nN , the number of questions and the maximum difficulty \nX Monk can solve.Next line contains N integers, Ai denoting the difficulty level of each question. Output Format\nMaximum score Monk can achieve in the exam.\n\nConstraints\n\n1N10^5\n1X10^9\n1Ai10^9.

“TESTCASE_1”: “7 6\n4 3 7 6 7 2 2\n###—###SEPERATOR—###—\n3”, “TESTCASE_2”: “8 3\n4 4 4 4 4 4 4 4\n###—###SEPERATOR—###—\n0”, “TESTCASE_3”: “10 15\n2 3 54 29 4 4 2 5 6 7\n###—###SEPERATOR—###—\n2”, “TESTCASE_4”: “8 4\n3 3 3 3 3 3 3 3\n###—###SEPERATOR—###—\n8”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

#include<stdio.h>
int main()
{
int i;
long long int n,x,count=0,count1=0;
scanf("%lld",&n);
scanf("%lld",&x);
long long int a[n];
for(i=0;i<n;i++)
{
 scanf("%lld",&a[i]);
}
for(i=0;i<n;i++)
{
 if(a[i]<=x&&count1!=2)
 {
  count++;
 }
 else if(a[i]>x&&count1!=2)
 {
   count1++;
 }
}
printf("%lld",count);
  return 0;
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock