/* -*- coding: utf-8 -*- * * 1225.cc: No.1225 I hate I hate Matrix Construction - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 500; /* typedef */ /* global variables */ int ss[MAX_N], ts[MAX_N]; int hs[MAX_N], vs[MAX_N], as[MAX_N][MAX_N]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", ss + i); for (int i = 0; i < n; i++) scanf("%d", ts + i); int cnt = 0; for (int y = 0; y < n; y++) if (ss[y] == 2) for (int x = 0; x < n; x++) if (! as[y][x]) as[y][x] = vs[x] = 1, cnt++; for (int x = 0; x < n; x++) if (ts[x] == 2) for (int y = 0; y < n; y++) if (! as[y][x]) as[y][x] = hs[y] = 1, cnt++; int osn = 0, otn = 0; for (int y = 0; y < n; y++) if (ss[y] == 1 && ! hs[y]) osn++; for (int x = 0; x < n; x++) if (ts[x] == 1 && ! vs[x]) otn++; printf("%d\n", cnt + max(osn, otn)); return 0; }