Problem Statement:
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-
- Score of the student is equal to the maximum number of answers he/she has attempted without skipping a question.
- Student is allowed to skip just "one" question that will not be counted in the continuity of the questions.
Note- Assume the student knows the solution to the problem he/she attempts and always starts the paper from first question.
Given the number of Questions, N ,the maximum difficulty level of the problem Monk can solve , ,and the difficulty level of each question , can you help him determine his maximum score?
Input Format
First Line contains Integer , the number of questions and the maximum difficulty Monk can solve.
Next line contains integers, denoting the difficulty level of each question.
First Line contains Integer , the number of questions and the maximum difficulty Monk can solve.
Next line contains integers, denoting the difficulty level of each question.
Output Format
Maximum score Monk can achieve in the exam.
Maximum score Monk can achieve in the exam.
Constraints
Programming using python 2.7.6:
N, X = map(int,raw_input().split())
A = map(int,raw_input().split()[:N])
score = 0
skip = 0
for i in A:
if skip > 1:
break
else:
if i > X:
skip +=1
else:
score +=1
No comments:
Post a Comment