/* -*- coding: utf-8 -*- * * 3434.cc: No.3434 [Cherry 8th Tune N] 螟ァ縺阪¥縺励※ Hold on Card! - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ using ll = long long; using pii = pair; /* global variables */ int as[MAX_N], bs[MAX_N]; pii ais[MAX_N]; char s[MAX_N + 4]; /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); for (int i = 0; i < n; i++) scanf("%d", bs + i); for (int i = 0; i < n; i++) ais[i] = {as[i], i}; sort(ais, ais + n); ll sc = 0; for (int i = 0; i < n; i++) sc += ais[i].first; ll maxsc = sc; int maxl = 0; for (int i = 0; i < n; i++) { sc += bs[i] - ais[i].first; if (maxsc < sc) maxsc = sc, maxl = i + 1; } fill(s, s + n, '0'); for (int i = 0; i < maxl; i++) s[ais[i].second] = '1'; s[n] = '\0'; puts(s); } return 0; }