A Sad Legend of Sejong and Yeongjae
InterviewTime limit1sMemory limit1024 MB
Assign each of the N bags to a different day so that every day receives at least its minimum A_i, or report -1 if no assignment exists.
Problem
Sejong lent money to Yeongjae, and he still has not been repaid. Sejong asked for the money many times, but sadly Yeongjae does not seem to understand him. So Sejong gave Yeongjae a final grace period of days. Yeongjae must repay all the money he borrowed within these days.
Sejong and Yeongjae follow a peculiar rule. On day , Sejong gets angry by . If Sejong does not receive at least won on day , he lashes out at Yeongjae. Yeongjae divides his money into bags and gives Sejong one bag per day.
Given the minimum amounts Sejong must receive each day and the amounts Yeongjae packed into the bags, write a program that finds a way for Yeongjae to repay the debt without triggering Sejong's anger.
Input
The first line contains , the number of days in the grace period.
The second line contains positive integers , separated by spaces. is the minimum amount Sejong must receive on day .
The third line contains positive integers , separated by spaces. is the amount Yeongjae put into bag .
and .
Output
Print the amount Yeongjae must pay on each day from day 1 to day , separated by spaces.
If it is impossible to repay the debt without Sejong becoming angry, print -1 instead.
If several answers are possible, print any one of them.