234C.md (2415B)
1 Source: https://codeforces.com/problemset/problem/234/C 2 3 C. Weather 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 input.txt 16 17 output 18 19 output.txt 20 21 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. 22 23 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. 24 25 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 < 0, *t*2 < 0, ..., *t**k* < 0 and *t**k* + 1 > 0, *t**k* + 2 > 0, ..., *t**n* > 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. 26 27 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. 28 29 Input 30 31 The first line contains a single integer *n* (2 ≤ *n* ≤ 105) — the number of days for which Vasya has been measuring the temperature. 32 33 The second line contains a sequence of *n* integers *t*1, *t*2, ..., *t**n* (|*t**i*| ≤ 109) — the sequence of temperature values. Numbers *t**i* are separated by single spaces. 34 35 Output 36 37 Print a single integer — the answer to the given task. 38 39 Examples 40 41 Input 42 43 ``` 44 4 45 -1 1 -2 1 46 ``` 47 48 Output 49 50 ``` 51 1 52 ``` 53 54 Input 55 56 ``` 57 5 58 0 -1 1 2 -5 59 ``` 60 61 Output 62 63 ``` 64 2 65 ``` 66 67 Note 68 69 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.