PivotOJ

Island Tour

시간 제한: 8000ms메모리 제한: 1024MB출처: NWERC 2020BOJ 21345

문제

Tijmen, Annemarie and Imme are visiting Iceland, a beautiful island country located in the middle of the Atlantic Ocean. To see as much of the island as possible, they would like to visit all of the tourist attractions on the Ring Road; the main road that runs around the circular perimeter of the island. There are nn attractions, conveniently numbered from 11 to nn in the order they appear along the road.

Unfortunately, current distancing measures only allow one visitor at a time at any given attraction, so they have decided to split up. Each person will start at a different attraction, visiting the remaining attractions in circular order around the Ring Road, i.e. a person starting their tour at attraction ii visits the attractions in the order ii, i+1i+1, \ldots, nn, 11, \ldots, i1i-1.

They know how long it takes to travel from one attraction to the next and how much time each person is going to spend at each attraction. They will each start their tour at the same time and---due to their impatience---will follow their plan without any waiting. Help Tijmen, Annemarie and Imme decide where each person should start their tour such that there never comes a time where more than one person is located at the same attraction. A person may enter an attraction at the same moment another person leaves the attraction, and when a person is finished visiting their last attraction they will immediately leave the attraction and return to their hotel.

입력

The input consists of:

  • One line with an integer nn (1n4001 \le n \le 400), the number of tourist attractions.
  • One line with nn integers d1,,dnd_1,\ldots,d_n (1di1061 \le d_i \le 10^6 for each ii), where did_i is the travel time in minutes from tourist attraction ii to i+1i+1 (or to 11 when i=ni = n).
  • For each of Tijmen, Annemarie and Imme:
    • One line with nn integers t1,,tnt_{1}, \ldots, t_{n} (1ti1061 \le t_{i} \le 10^6 for each ii), where tit_i is the time in minutes that the given person is going to spend at attraction ii.

출력

If there is a valid assignment, output one line with three integers, the starting attraction for each person.  Otherwise, output "impossible". If there are multiple valid solutions, you may output any one of them.

예제

예제 1

입력
6
1 1 1 1 1 1
2 1 3 2 3 1
8 7 4 9 7 2
7 6 2 9 2 1
출력
1 5 6

예제 2

입력
4
1 1 1 1
1 1 1 1
10 3 2 1
4 2 5 1
출력
impossible
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.