두 순열이 정한 순서를 따르는 정수 배열 a, b를 만들어 ai+bj<0인 쌍 (i, j), i<j의 개수가 정확히 k가 되게 한다.
어려움8그리디정렬투 포인터아직 제출이 없습니다시간 제한2초메모리 제한512 MBYou have two permutations of n elements, p1, p2, . . . , pn and q1, q2, . . . , qn, and one integer k.
You need to find two integer arrays, a and b, with the following properties:
The first line of the input contains two integers n and k: the number of elements and the required number of cool pairs (1 ≤ n ≤ 300 000, 0 ≤ k ≤ n·(n−1)/2).
The second line contains n space-separated integers: the permutation p1, p2, . . . , pn.
The third line contains n space-separated integers: the permutation q1, q2, . . . , qn.
It is guaranteed that each integer from 1 to n appears exactly once in each permutation.
If there is no such pair of integer arrays that the number of cool pairs is equal to k, print “No” on a single line.
Otherwise, print “Yes” on the first line, and print the arrays a and b on the next two lines. Separate array elements by spaces.