1862. Noise

单点时限: 2.0 sec

内存限制: 256 MB

I have a light that changes from on to off or from off to on when I clap twice. The light’s sensor samples the noise level in the room at short intervals and it triggers the light to change whenever it detects a low noise level followed by exactly 2 high noise levels followed by a low noise level.

“High” or “low” is based on a threshold noise level. When the sampled noise level is as high or higher than the threshold level, the noise level is classified as “high”; otherwise it is classified as “low”. I have a list of background that is a typical sequence of sensor readings when normal activity is taking place. I want software that will choose the threshold value so that it has the following properties:

1) It causes more than 50% of all the values in background to be classified “low”.

2) It is the lowest possible threshold value that satisfies the 50% rule and that does not cause background to trigger the light to change.

输入格式

There are several test cases,each test case contains 2 lines,the first line is a integer N(4<=N<=50),the next line contains N integers,shows the list of background(The numbers are between 0 and 1000 inclusive).

输出格式

For each test case,output the desired threshold value.

样例

Input
16
8 8 8 1 1 1 1 1 1 1 1 1 1 1 2 1
15
921 1 5 900 8 813 3 3 3 3 3 3 3 813 813
Output
2
4
Hint:
Case 1:
Remember that the high noise levels must be both preceded and followed by low noise levels to trigger the light.

6 人解决,16 人已尝试。

6 份提交通过,共有 39 份提交。

8.1 EMB 奖励。

创建: 16 年,7 月前.

修改: 7 年,2 月前.

最后提交: 3 年,12 月前.

来源: N/A

题目标签