Taotao picking apples

2: Tao Tao picks apples


Total time limit: 
1000ms
Memory limit: 
65536kB
describe

There is an apple tree in Tao Tao's yard, and every autumn, the tree will bear 10 apples. When the apples are ripe, Tao Tao will go to pick apples. Tao Tao has a bench that is 30 centimeters high. When she can't pick apples with her hands, she steps on the bench and tries again.

Now that you know the height of 10 apples to the ground, and the maximum height that Taotao can reach when she stretches her hand straight, please help Taotao to count the number of apples she can pick. Suppose she touches the apple, and the apple will fall.

enter
Contains two rows of data. The first line contains 10 integers (in centimeters) between 100 and 200 (including 100 and 200) representing the height of 10 apples to the ground, and two adjacent integers are separated by a space. The second line contains only an integer (in centimeters) between 100 and 120 (inclusive), indicating the maximum height that Tao Tao can reach with his hands straight.
output
Include a line that contains only an integer representing the number of apples that Taotao can pick.
sample input
100 200 150 140 129 134 167 198 200 111
110
Sample output


















#include<iostream>
using namespace std;
int main(){
	const int MAX = 11;
	int a[MAX];
	int len;
	
	for(int i=0;i<10;i++)
		cin>>a[i];
	cin >> len;
	
	len + = 30;
	int count=0;
	for(int i=0;i<10;i++){
		if(len>=a[i]) count++;
	}
	cout<<count<<endl;
	return 0;
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326976214&siteId=291194637