#461
Unrated
Falling Portals
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

There are NN (2N21052\le N\le 2\cdot 10^5) worlds, each with a portal. Initially, world ii (for 1iN1 \leq i \leq N) is at xx-coordinate ii, and yy-coordinate AiA_i (1Ai1091\le A_i\le 10^9). There is also a cow on each world. At time 00, all yy-coordinates are distinct and the worlds start falling: world ii moves continuously in the negative-yy direction at a speed of ii units per second.

At any time when two worlds are at the same yy-coordinate (possibly a fractional time), the portals "align", meaning that a cow on one of the worlds can choose to travel instantaneously to the other world.

For each ii, the cow on world ii wants to travel to world QiQ_i (QiiQ_i\neq i). Help each cow determine how long her journey will take, if she travels optimally.

Each query output should be a fraction a/ba/b where aa and bb are positive and relatively prime integers, or 1-1 if it the journey is impossible.

SCORING:

Test cases 2-3 satisfy N100.N\le 100.Test cases 4-5 satisfy N2000.N\le 2000.Test cases 6-14 satisfy no additional constraints.

입력

The first line of input contains a single integer N.N.

The next line contains NN space-separated integers A1,A2,,AN.A_1,A_2,\ldots,A_N.

The next line contains NN space-separated integers Q1,Q2,,QN.Q_1,Q_2,\ldots,Q_N.

출력

Print NN lines, the ii-th of which contains the journey length for cow i.i.

예제 입력 1

4
3 5 10 2
3 3 2 1

예제 출력 1

7/2
7/2
5/1
-1
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.