問題一覧 > 通常問題

No.3434 [Cherry 8th Tune N] Make It Bigger, Hold on Card!

レベル : / AI推定難易度 : 750 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 62
作問者 : 👑 Kazun / テスター : kazuppa
お気に入りにしたユーザー ProblemId : 10142 / 自分の提出
問題文最終更新日: 2026-01-23 00:38:16
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 491 Go on Back!! (順位表) の他の問題:

Problem Visual

▶ Open to reveal the problem visual

Notice

If the judge result is QLE, there may be an error in the problem or in the judge. Please report it.

Problem Statement

Cherry-chan has $N$ red cards in her hand. The $i$-th red card has the integer $A_i$ written on it.

Separately from her hand, $N$ blue cards are stacked in a deck, and the $j$-th blue card from the top has the integer $B_j$ written on it.

Cherry-chan performs the following actions in order.

  • From the $N$ red cards she holds, she chooses any number of cards, $0$ or more. Then, she eats all of the chosen cards.
  • She draws blue cards in order from the top, the same number as the red cards she ate, and adds them to her hand.

After these actions, Cherry-chan holds a total of $N$ cards, red and blue. The sum of the integers written on these $N$ cards is called the score.

Give $1$ way of eating red cards that maximizes the score.

Solve $T$ test cases.

Constraints

  • $1 \leq T \leq 2 \times 10^5$.
  • Constraints for each test case
    • $1 \leq N \leq 2 \times 10^5$.
    • $-10^9 \leq A_i \leq 10^9 \quad (1 \leq i \leq N)$.
    • $-10^9 \leq B_j \leq 10^9 \quad (1 \leq j \leq N)$.
  • Constraints for the entire test file
    • The sum of $N$ over the $T$ test cases is at most $2 \times 10^5$.
    • All input values are integers.

Input

$T$

Each test case is given in the following format.

$N$
$A_1$ $\dots$ $A_N$
$B_1$ $\dots$ $B_N$

Output

The output consists of $T$ lines. On line $t~(1 \leq t \leq T)$, output a string $S$ of length $N$ consisting of 0 and 1, defined as follows.

  • If the $i$-th red card is not eaten, the $i$-th character of $S$ is 0; if the $i$-th red card is eaten, the $i$-th character of $S$ is 1.

If there are multiple ways of eating that maximize the score, you may give any $1$ of them.

Sample

Sample 1
Input
3
3
10 30 20
15 25 5
4
1 2 3 4
100 200 300 400
6
0 0 0 0 0 0
100 -1000 0 0 0 0
Output
101
1111
001000
  • [Test case $1$] Cherry-chan initially has $3$ red cards, with the integers $10, 30, 20$ written on them. Also, $3$ blue cards are stacked as a deck, and the integers written on the blue cards are $15, 25, 5$ in order from the top.

    Suppose Cherry-chan eats the $1, 3$-th red cards and draws $2$ blue cards, the same number as the red cards she ate. After this action, the integers written on the $3$ cards she holds are $15, 30, 25$ in some order.

    This action gives a score of $15 + 30 + 25 = 70$. Also, the score cannot be made greater than $70$, so $S=$ 101 is a correct answer.

    Note that Cherry-chan can freely choose which red cards to eat, but blue cards can only be drawn from the top of the deck.

  • [Test case $2$] To maximize the score, she must eat all $4$ cards she holds and draw $4$ cards from the deck.
  • [Test case $3$] Any way of eating exactly $1$ of the $6$ cards maximizes the score. Therefore, not only 001000 but also 000010 and 100000 are correct answers for $S$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。