Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<cmath>
- using namespace std;
- long long n, c, p;
- int main(){
- cin >> n;
- vector <long long> a(n + 1); c = 0; p = 1; bool zero = false;
- for (long long i = 1; i < n + 1; ++i){
- cin >> a[i];
- c += abs(abs(a[i]) - 1);
- if (a[i] < 0) p *= -1;
- if (a[i] == 0) zero = true;
- }
- if (p == 1) cout << c;
- else if (zero) cout << c;
- else cout << c + 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment