VK Cup 2012 Round 1
A
Dress'em in Vests!
Codeforces
1300
原题
←B →
翻译中…

The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straight line.

翻译中…

The Two-dimensional kingdom has a regular army of $*n*$ people. Each soldier registered himself and indicated the desired size of the bulletproof vest: the $*i*$-th soldier indicated size $*a*_{*i*}$. The soldiers are known to be unpretentious, so the command staff assumes that the soldiers are comfortable in any vests with sizes from $*a*_{*i*} - *x*$ to $*a*_{*i*} + *y*$, inclusive (numbers $*x*, *y* ≥ 0$ are specified).

翻译中…

The Two-dimensional kingdom has $*m*$ vests at its disposal, the $*j*$-th vest's size equals $*b*_{*j*}$. Help mobilize the Two-dimensional kingdom's army: equip with vests as many soldiers as possible. Each vest can be used only once. The $*i*$-th soldier can put on the $*j*$-th vest, if $*a*_{*i*} - *x* ≤ *b*_{*j*} ≤ *a*_{*i*} + *y*$.

翻译中…

Input

翻译中…

The first input line contains four integers $*n*$, $*m*$, $*x*$ and $*y*$ ($1 ≤ *n*, *m* ≤ 10^{5}$, $0 ≤ *x*, *y* ≤ 10^{9}$) — the number of soldiers, the number of vests and two numbers that specify the soldiers' unpretentiousness, correspondingly.

翻译中…

The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{9}$) in non-decreasing order, separated by single spaces — the desired sizes of vests.

翻译中…

The third line contains $*m*$ integers $*b*_{1}, *b*_{2}, ..., *b*_{*m*}$ ($1 ≤ *b*_{*j*} ≤ 10^{9}$) in non-decreasing order, separated by single spaces — the sizes of the available vests.

翻译中…

Output

翻译中…

In the first line print a single integer $*k*$ — the maximum number of soldiers equipped with bulletproof vests.

翻译中…

In the next $*k*$ lines print $*k*$ pairs, one pair per line, as "$*u*_{*i*}$ $*v*_{*i*}$" (without the quotes). Pair ($*u*_{*i*}$, $*v*_{*i*}$) means that soldier number $*u*_{*i*}$ must wear vest number $*v*_{*i*}$. Soldiers and vests are numbered starting from one in the order in which they are specified in the input. All numbers of soldiers in the pairs should be pairwise different, all numbers of vests in the pairs also should be pairwise different. You can print the pairs in any order.

翻译中…

If there are multiple optimal answers, you are allowed to print any of them.

翻译中…

Note

翻译中…

In the first sample you need the vests' sizes to match perfectly: the first soldier gets the first vest (size 1), the third soldier gets the second vest (size 3). This sample allows another answer, which gives the second vest to the fourth soldier instead of the third one.

翻译中…

In the second sample the vest size can differ from the desired size by at most 2 sizes, so all soldiers can be equipped.

翻译中…

样例

Input #1
5 3 0 0
1 2 3 3 4
1 3 5
Output #1
2
1 1
3 2
InputCopy OutputCopy
Input #2
3 3 2 2
1 5 9
3 5 7
Output #2
3
1 1
2 2
3 3
InputCopy OutputCopy
题目信息
题号
161A
时间限制
3 s
内存限制
256 MB
标签
二分
暴力
贪心
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。