301249: CF234C. Weather

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Weather

题意翻译

## 题目描述 科学家们对全球变暖和地球降温的问题说了很多。事实上,这种自然现象强烈影响着我们星球上的所有生命。 我们的英雄Vasya非常关心这些问题。他决定做一个小小的实验,观察室外的温度是如何变化的。他每天早上在阳台上挂一个温度计,记录下温度。 他过去的n天都在测量温度。因此,他得到了一组数据: $t_1$,$t_2$......$t_n$,其中,$t_i$表示第i天温度。 Vasya分析了其他城市的温度统计数据,得出结论:如果先是室外温度为负的一些非零天数,然后温度为正的一些非零天数,那么这个城市就没有环境问题。 更确切地说,必须存在一个正整数k(1<=k<=n-1),使得$t_1$<0,$t_2$<0......$t_k$<0并且其余的数据大于0。 还有一个特殊的要求:温度永远不应该是零。 如果不满足这个条件,Vesya决定他的城市有环境问题,并感到不安!! 你不想让Vesya难过。因此,您需要选择多个温度值并修改它们以满足Vasya的条件。你需要知道需要改变的最小温度值的数目。 ## 输入格式 第一行包括一个正整数n(2<=n<=$10^5$),代表Vesya所测量的天数。 第二行有n个正整数:$t_1$,$t_2$......$t_k$,(|$t_i$|<=$10^9$)代表这n天的温度,被空格隔开。 ## 输出格式 一个正整数,即给定任务的答案。 ## 说明和提示 对于第一个样例:有两种方法可以改变一个数字,使序列符合Vasya的条件。你可以用任何负数替换第一个数字1,也可以用任何正数替换数字-2。

题目描述

Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet. Our hero Vasya is quite concerned about the problems. He decided to try a little experiment and observe how outside daily temperature changes. He hung out a thermometer on the balcony every morning and recorded the temperature. He had been measuring the temperature for the last $ n $ days. Thus, he got a sequence of numbers $ t_{1},t_{2},...,t_{n} $ , where the $ i $ -th number is the temperature on the $ i $ -th day. Vasya analyzed the temperature statistics in other cities, and came to the conclusion that the city has no environmental problems, if first the temperature outside is negative for some non-zero number of days, and then the temperature is positive for some non-zero number of days. More formally, there must be a positive integer $ k $ ( $ 1<=k<=n-1 $ ) such that $ t_{1}&lt;0,t_{2}&lt;0,...,t_{k}&lt;0 $ and $ t_{k+1}&gt;0,t_{k+2}&gt;0,...,t_{n}&gt;0 $ . In particular, the temperature should never be zero. If this condition is not met, Vasya decides that his city has environmental problems, and gets upset. You do not want to upset Vasya. Therefore, you want to select multiple values of temperature and modify them to satisfy Vasya's condition. You need to know what the least number of temperature values needs to be changed for that.

输入输出格式

输入格式


The first line contains a single integer $ n $ ( $ 2<=n<=10^{5} $ ) — the number of days for which Vasya has been measuring the temperature. The second line contains a sequence of $ n $ integers $ t_{1},t_{2},...,t_{n} $ $ (|t_{i}|<=10^{9}) $ — the sequence of temperature values. Numbers $ t_{i} $ are separated by single spaces.

输出格式


Print a single integer — the answer to the given task.

输入输出样例

输入样例 #1

4
-1 1 -2 1

输出样例 #1

1

输入样例 #2

5
0 -1 1 2 -5

输出样例 #2

2

说明

Note to the first sample: there are two ways to change exactly one number so that the sequence met Vasya's condition. You can either replace the first number 1 by any negative number or replace the number -2 by any positive number.

Input

题意翻译

## 题目描述 科学家们对全球变暖和地球降温的问题说了很多。事实上,这种自然现象强烈影响着我们星球上的所有生命。 我们的英雄Vasya非常关心这些问题。他决定做一个小小的实验,观察室外的温度是如何变化的。他每天早上在阳台上挂一个温度计,记录下温度。 他过去的n天都在测量温度。因此,他得到了一组数据: $t_1$,$t_2$......$t_n$,其中,$t_i$表示第i天温度。 Vasya分析了其他城市的温度统计数据,得出结论:如果先是室外温度为负的一些非零天数,然后温度为正的一些非零天数,那么这个城市就没有环境问题。 更确切地说,必须存在一个正整数k(1<=k<=n-1),使得$t_1$<0,$t_2$<0......$t_k$<0并且其余的数据大于0。 还有一个特殊的要求:温度永远不应该是零。 如果不满足这个条件,Vesya决定他的城市有环境问题,并感到不安!! 你不想让Vesya难过。因此,您需要选择多个温度值并修改它们以满足Vasya的条件。你需要知道需要改变的最小温度值的数目。 ## 输入格式 第一行包括一个正整数n(2<=n<=$10^5$),代表Vesya所测量的天数。 第二行有n个正整数:$t_1$,$t_2$......$t_k$,(|$t_i$|<=$10^9$)代表这n天的温度,被空格隔开。 ## 输出格式 一个正整数,即给定任务的答案。 ## 说明和提示 对于第一个样例:有两种方法可以改变一个数字,使序列符合Vasya的条件。你可以用任何负数替换第一个数字1,也可以用任何正数替换数字-2。

加入题单

算法标签: