Rainy Markets

아직 제출이 없습니다시간 제한1.5초메모리 제한1024 MB

문제

There are NN covered bus shelters, labelled 1,,N1, \ldots, N. The ithi^\text{th} bus shelter can fit B_iB\_i people inside.

For each i1,,N1i \in \\{1, \ldots, N - 1\\}, there is a sidewalk connecting bus shelter ii to bus shelter i+1i + 1, with an open-air market in the middle. The ithi^\text{th} market has U_iU\_i umbrellas for sale, each costing \\1$.

Right now, the ithi^\text{th} market has P_iP\_i people inside, and every person is in a market so all the bus shelters are empty.

Suddenly, it starts raining, and everyone at market ii has to decide between three possibilities:

  • to go to bus shelter ii;
  • to go to bus shelter i+1i + 1; or
  • to stay and buy an umbrella.

If a person is unable to find a place in a bus shelter or buy an umbrella, they will get wet.

If everyone coordinates optimally, can they all stay dry? If so, what is the least amount of money they need to spend, and which bus shelter should each person move to?

입력

The first line of input contains an integer NN.

The second line of input contains NN space-separated integers B_iB\_i (1iN)(1 \le i \le N), the capacity of bus shelter ii.

The third line of input contains N1N - 1 space-separated integers P_iP\_i (1iN1)(1 \le i \le N - 1), the number of people at market ii.

The fourth line of input contains N1N - 1 space-separated integers U_iU\_i (1iN1)(1 \le i \le N - 1), the number of umbrellas for sale at market ii.

출력

If every person can stay dry either under an umbrella or at a bus shelter, the output will be N+1N + 1 lines:

  • the first line will contain the word YES.

  • the second line will contain the least amount of money necessary to spend on umbrellas

  • the next N1N - 1 lines will each contain three space-separated integers:

    • the number of people at market ii moving to bus shelter ii
    • the number of people at market ii buying an umbrella
    • the number of people at market ii moving to bus shelter i+1i + 1, where 1iN11 \le i \le N - 1.

If not every person can stay dry, the output will be one line containing the word NO.

If there are multiple possible correct outputs, any correct output will be accepted.