HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


012. 50352 - Selling Cows

Guest
• Review clarifications (1)

Volume problems

• 51046 - The biggest number
• 50867 - Average of the Best Grades
• Reflektimi i pikes
• 50994 - The Most Crowded Station
• 51194 - The difference between max...
• 002. 50554 - nth power of m
• 004. 50424 - Area
• 004. 50522 - Multiplication Table - 2
• 012. 50352 - Selling Cows
• 017. 50537 - esreveR Triangle
• 018. 50491 - Brokers
• 018. 50787 - Expected Value
• 020. 50485 - Center of gravity of a ...
• 024. 50372 - Number Quadruplets
• 025- 2013-Nov-01. 50328 - How far ...
• 026. 50487 - Radius of Inscribed Circle
• 027. 50548 - Albanian Airlines

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Selling Cows

Farmer John has many cows. Time to time he goes to sell some of them. He doesn't sell a cow if it's smaller than or equal to certain weight (w). And, he tries to sell the smallest one that is heavier than w.

Question:
Write a program that finds the cow that is the smallest of the ones which are heavier than w kgs.

Input specification
You will be given two integer numbers (n and w) at the beginning where 1 ≤ n ≤ 5000 and 1 ≤ k ≤ 1000. Then, in the following n lines, you will be given n integers: the weights of n cows.

Output specification
Show just one integer number: the position of the first cow which complies the given condition. If there is no cow that is heavier than w then show -1.
Note: Positions start from 1.

 Sample Input I   
  7 10
  7 15 10 8 17 11 20
 Sample Input II   
  6 50
  12 30 28 7 41 50
 Sample Output I   
  6
 Sample Output II   
  -1


Для отправки решений необходимо выполнить вход.

www.contester.ru