time limit per test
1 second
memory limit per test
256 megabytes
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][A1,A2,A3,…,AN]. In one operation, Chaneka can choose one element, then increase or decrease the element's value by 11. 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=0A1×A2×A3×…×AN=0?
Input
The first line contains a single integer NN (1≤N≤1051≤N≤105).
The second line contains NN integers A1,A2,A3,…,ANA1,A2,A3,…,AN (−105≤Ai≤105−105≤Ai≤105).
Output
An integer representing the minimum number of operations that must be done to make it such that A1×A2×A3×…×AN=0A1×A2×A3×…×AN=0.
Examples
Input
Copy
3 2 -6 5
Output
Copy
2
Input
Copy
1 -3
Output
Copy
3
Input
Copy
5 0 -1 0 1 0
Output
Copy
0
Note
In the first example, initially, A1×A2×A3=2×(−6)×5=−60A1×A2×A3=2×(−6)×5=−60. Chaneka can do the following sequence of operations:
- Decrease the value of A1A1 by 11. Then, A1×A2×A3=1×(−6)×5=−30A1×A2×A3=1×(−6)×5=−30
- Decrease the value of A1A1 by 11. Then, A1×A2×A3=0×(−6)×5=0A1×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
解题说明:水题,找到绝对值最小的数,然后将该数变成0即可。
#include<stdio.h>
int main()
{int n, x, ans = 1e5;scanf("%d", &n);for (int i = 0; i < n; ++i){scanf("%d", &x);if (abs(x) <= ans){ans = abs(x);}}printf("%d", ans);return 0;
}