CF161A.Dress'em in Vests!

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn people. Each soldier registered himself and indicated the desired size of the bulletproof vest: the ii -th soldier indicated size aia_{i} . The soldiers are known to be unpretentious, so the command staff assumes that the soldiers are comfortable in any vests with sizes from aixa_{i}-x to ai+ya_{i}+y , inclusive (numbers x,y>=0x,y>=0 are specified).

The Two-dimensional kingdom has mm vests at its disposal, the jj -th vest's size equals bjb_{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 ii -th soldier can put on the jj -th vest, if aix<=bj<=ai+ya_{i}-x<=b_{j}<=a_{i}+y .

输入格式

The first input line contains four integers nn , mm , xx and yy ( 1<=n,m<=1051<=n,m<=10^{5} , 0<=x,y<=1090<=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 nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1091<=a_{i}<=10^{9} ) in non-decreasing order, separated by single spaces — the desired sizes of vests.

The third line contains mm integers b1,b2,...,bmb_{1},b_{2},...,b_{m} ( 1<=bj<=1091<=b_{j}<=10^{9} ) in non-decreasing order, separated by single spaces — the sizes of the available vests.

输出格式

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

In the next kk lines print kk pairs, one pair per line, as " uiu_{i} viv_{i} " (without the quotes). Pair ( uiu_{i} , viv_{i} ) means that soldier number uiu_{i} must wear vest number viv_{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.

输入输出样例

  • 输入#1

    5 3 0 0
    1 2 3 3 4
    1 3 5
    

    输出#1

    2
    1 1
    3 2
    
  • 输入#2

    3 3 2 2
    1 5 9
    3 5 7
    

    输出#2

    3
    1 1
    2 2
    3 3
    

说明/提示

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.

首页