Under construction

Still being built. Things may change

Candy Boxes

Time limit2sMemory limit1024 MB

Summary
Given N and a candy box of size a x b x c, find a large box whose three sides sum to at most N and that holds the most candy boxes in the same orientation.
Level

Medium6 of 10

Topics
Math, Brute force
Solved
No attempts yet

Statement

Petya lives in city P, where a candy factory makes very tasty candies. Petya plans to travel by train to city M to visit his friend Vasya. He wants to bring as many boxes of candy as possible as a gift.

Each candy box has size a×b×ca \times b \times c cm, where aa is the length, bb is the width, and cc is the height. Petya uses one large box shaped like a rectangular parallelepiped. All candy boxes must fit inside it. Each candy box must keep its original orientation, and all of them must face the same direction. Petya may choose any size for the large box, but the sum of its three dimensions cannot exceed NN cm under the railway rules.

Write a program that, given NN, aa, bb, and cc, finds the size of the box Petya should use so that it holds the maximum number of candy boxes.

Input

The first line contains four integers separated by spaces: NN, aa, bb, and cc (1≤N,a,b,c≤1091 \le N, a, b, c \le 10^9).

Output

Print three numbers: the length, width, and height of the box Petya should choose, so that the maximum number of candy boxes fits. If several answers are possible, print any of them.

Hint

In the first example, the best choice is a 3×4×33 \times 4 \times 3 cm box. Three candy boxes fit along the length, two along the width, and one along the height.

In the second example, at least two candy boxes require a box of at least 8×3×48 \times 3 \times 4 cm, whose dimensions sum to 15. Such a box holds at most one candy box. The 9×3×29 \times 3 \times 2 box is also a valid answer, even though it is not the smallest one.

Examples2

  1. Example 1

    Input
    10 1 2 3
    
    Expected output
    3 4 3
    
  2. Example 2

    Input
    14 8 3 2
    
    Expected output
    9 3 2