Error Swap

AtCoder
IDarc198_c
Time2000ms
Memory256MB
Difficulty
You are given two integer sequences of length $N$: $A=(A_1,A_2,\dots,A_N)$ and $B=(B_1,B_2,\dots,B_N)$. You may perform at most $31000$ operations of the following kind: * Choose a pair of integers $(i,j)$ with $1 \le i < j \le N$, then replace $A_i$ with $A_j - 1$ and $A_j$ with $A_i + 1$. Your goal is to make $A = B$. Determine whether the goal is achievable, and if it is, output one sequence of operations that achieves it. ## Constraints * $2 \le N \le 100$ * $1 \le A_i,B_i \le 100$ ## Input The input is given from Standard Input in the following format: $N$ $A_1\ A_2\ \dots\ A_N$ $B_1\ B_2\ \dots\ B_N$ [samples]
Samples
Input #1
4
2 2 1 4
3 2 2 2
Output #1
Yes
2
1 4
3 4

The following operations make $A = B$:

*   Choose $(i,j) = (1,4)$. Then $A = (3,2,1,3)$.
*   Choose $(i,j) = (3,4)$. Then $A = (3,2,2,2)$.

Since minimizing the number of operations is not required, the following output is also accepted:

Yes
6
1 4
3 4
1 2
1 2
1 2
1 2
Input #2
6
5 4 4 3 4 2
5 1 2 3 4 1
Output #2
No
Input #3
7
2 4 2 4 3 2 5
5 4 3 2 5 1 2
Output #3
Yes
18
5 7
1 7
2 4
1 5
1 5
1 4
4 5
4 5
3 4
5 7
1 5
1 7
1 6
6 7
1 7
2 4
2 5
4 5
API Response (JSON)
{
  "problem": {
    "name": "Error Swap",
    "description": {
      "content": "You are given two integer sequences of length $N$: $A=(A_1,A_2,\\dots,A_N)$ and $B=(B_1,B_2,\\dots,B_N)$. You may perform at most $31000$ operations of the following kind: *   Choose a pair of integers",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc198_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given two integer sequences of length $N$: $A=(A_1,A_2,\\dots,A_N)$ and $B=(B_1,B_2,\\dots,B_N)$.\nYou may perform at most $31000$ operations of the following kind:\n\n*   Choose a pair of integers...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments