CF1157E.Minimum Array
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two arrays a and b , both of length n . All elements of both arrays are from 0 to n−1 .
You can reorder elements of the array b (if you want, you may leave the order of elements as it is). After that, let array c be the array of length n , the i -th element of this array is ci=(ai+bi)%n , where x%y is x modulo y .
Your task is to reorder elements of the array b to obtain the lexicographically minimum possible array c .
Array x of length n is lexicographically less than array y of length n , if there exists such i ( 1≤i≤n ), that xi<yi , and for any j ( 1≤j<i ) xj=yj .
输入格式
The first line of the input contains one integer n ( 1≤n≤2⋅105 ) — the number of elements in a , b and c .
The second line of the input contains n integers a1,a2,…,an ( 0≤ai<n ), where ai is the i -th element of a .
The third line of the input contains n integers b1,b2,…,bn ( 0≤bi<n ), where bi is the i -th element of b .
输出格式
Print the lexicographically minimum possible array c . Recall that your task is to reorder elements of the array b and obtain the lexicographically minimum possible array c , where the i -th element of c is ci=(ai+bi)%n .
输入输出样例
输入#1
4 0 1 2 1 3 2 1 1
输出#1
1 0 0 2
输入#2
7 2 5 1 5 3 4 3 2 4 3 5 6 5 1
输出#2
0 0 0 1 0 2 4