-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB.cpp
64 lines (62 loc) · 1.93 KB
/
B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Created by ahmed_drawy on 07/09/19.
/// Codeforces Round #580 (Div. 2)
#include <bits/stdc++.h>
#include <string.h>
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;
#define lp(i,start , end) for(int i = start ; i<end ; ++i)
#define lllp(i,start , end) for(ll i = start ; i<end ; ++i)
#define inN(arr , n) for(int i = 0 ; i< n ; ++i) cin>>arr[i];
#define Rlp(i,start , end) for(int i = start ; i>end ; --i)
#define all(v) ((v).begin(),(v).end())
#define sz(v) (int)((v).size())
#define clr(v,d) memset(v , d , sizeof(v))
#define inf 0x3f3f3f3f
//#define dbg (v) for(auto it : v)cout<<it<<' ';
typedef long long ll;
typedef vector<int> vi;
typedef vector <ll> vll;
typedef vector<vector<int> > adj;
typedef pair<int ,int> pii;
const double EPS =1e-7;
const int OO = 1e6;
#define endl '\n'
bool sortpair( const pair<int , int> & x, const pair<int , int> & y){
return x.first != y.first ? x.first < y.first : x.second > y.second ;
}
int dcomp(double x , double y){
return fabs(x-y) <= EPS? 0: x>y?1:-1;
}
void smile() {
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);
// freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);
#endif
}
int main() {
smile();
int n ; cin >> n ;
ll ans = 0 , neg = 0 , zero =0; ;
lp(i,0,n){
ll x ;
cin >>x;
if(x <0 ){
ans +=abs(x - (-1));
neg++;
}
else if(x == 0 ){
zero++;
}
else if(x >= 1) ans+=abs(x - 1);
}
if(neg &1){
if(zero){
cout << ans + zero;
}
else
cout << ans +2 ;
}
else cout << ans + zero;
}