P1046 Tao Tao picking apples Python implementation

Title Description

Tao Tao family's yard has an apple tree, every autumn tree will bear 10 1 0 apple. Apple ripe, Tao Tao will go apple-picking. Tao Tao has a 30 3 0 cm high bench, when she can not directly hand to pick apples and they will try again stepped on the bench.

Now known 10 1 0 apple to the ground level, and Tao Tao handle straight time to reach the maximum height, Tao Tao please help her to count the number of apples to pick. Assuming that she met apples, apple will fall.

Input Format

Input data consists of two lines. The first row contains 10 . 1 0 100 . 1 0 to 0 200 is 2 0 0 (including 100 . 1 0 0 and 200 is 2 0 an integer of 0) (in centimeters), respectively, showing 10 . 1 height to the ground apple 0 , between two adjacent integers separated by a space. The second row includes only a 100 . 1 0 0 to 120 . 1 2 0 (containing 100 . 1 0 0 and 120 . 1 2 integer of 0) (in centimeters), Toto represents straight handle when the maximum height can be achieved .

Output Format

Including output line, which contains only an integer representing the number of Toto able to pick apples.

Sample input and output

Input # 1
100 200 150 140 129 134 167 198 200 111
110
Output # 1
5

Description / Tips

NOIP2005 universal set of first title

-------------------------------------------------------------------------------------

Do not talk nonsense, the first on the code (pro-test AC, safe to eat)

a = input().split()
c=[]
for i in range(0,10):
    c.append(0)
    c[i] = int(a[i])
c.sort()
b = int(input())
for i in range(0,10):
    if(c[i]>b+30):
        print(i)
        break

Tao Tao was able to pick apples

Trunk height <= height +30

The following figure (excuse my drawing skill is not good)

That change a way of thinking we just need to sort the original array (as shown below)

Finally, to find a less height Toto at position -1 to +30.

Guess you like

Origin www.cnblogs.com/yeah123/p/11964122.html
Recommended