CF1866A.Ambitious Kid
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Chaneka, Pak Chanek's child, is an ambitious kid, so Pak Chanek gives her the following problem to test her ambition.
Given an array of integers [A1,A2,A3,…,AN] . In one operation, Chaneka can choose one element, then increase or decrease the element's value by 1 . Chaneka can do that operation multiple times, even for different elements.
What is the minimum number of operations that must be done to make it such that A1×A2×A3×…×AN=0 ?
输入格式
The first line contains a single integer N ( 1≤N≤105 ).
The second line contains N integers A1,A2,A3,…,AN ( −105≤Ai≤105 ).
输出格式
An integer representing the minimum number of operations that must be done to make it such that A1×A2×A3×…×AN=0 .
输入输出样例
输入#1
3 2 -6 5
输出#1
2
输入#2
1 -3
输出#2
3
输入#3
5 0 -1 0 1 0
输出#3
0
说明/提示
In the first example, initially, A1×A2×A3=2×(−6)×5=−60 . Chaneka can do the following sequence of operations:
- Decrease the value of A1 by 1 . Then, A1×A2×A3=1×(−6)×5=−30
- Decrease the value of A1 by 1 . Then, A1×A2×A3=0×(−6)×5=0
In the third example, Chaneka does not have to do any operations, because from the start, it already holds that A1×A2×A3×A4×A5=0×(−1)×0×1×0=0