Appleby Contest '19 P1 - Darcy's Debilitating Demands

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Darcy (a former taxi driver) now works at a factory crunching numbers for calculations. Despite his superior intellect and mathematical abilities, he still finds his job of calculating and computing very cumbersome and difficult.

Today he has to complete T tasks, each in the following format:

Given four numbers N, A, B, C, find three numbers that sum up to N, with the following restrictions:

  • The first number must be an integer between 0 and A (inclusive)
  • The second number must be an integer between 0 and B (inclusive)
  • The third number must be an integer between 0 and C (inclusive)

Darcy has been feeling very pooped lately, can you help him find the three numbers for each task?

Constraints

1 \le T \le 100

1 \le N, A, B, C \le 10^9

Input Specification

The first line will contain the integer T, the number of tasks. T tasks will follow in the next 4T lines.

The first line of each task will contain the integer N.

The next three lines of each task will contain three integers: A, B, C.

Output Specification

For each task, output three integers that sum up to N and satisfy the above constraints, or -1 if that is not possible.

If there are multiple solutions, output the one such that earlier numbers are minimized. Note that A is considered to be before B and C and B is considered to be before C,

Sample Input
1
100
100
53
49
Sample Output
0 51 49
Explanation

Note that there is only one task in the sample.

While 98 1 1 also sums up to 100, the earlier numbers should be as small as possible.


Comments


  • -5
    CarlosJin  commented on Oct. 26, 2020, 4:55 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 3
      Plasmatic  commented on Oct. 26, 2020, 8:38 a.m.

      My Python solution passes in <0.09s in the worst case... the time limit is very generous


  • 1
    p  commented on Aug. 10, 2020, 5:52 p.m. edited

    Why isn't the expected output ?

    100 0 0

    Edit: Sorry I didn't read the whole question!


  • -16
    yeebruh21  commented on Aug. 1, 2020, 12:48 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 0
      Lele567  commented on Sept. 3, 2020, 11:35 a.m.

      Free points then


    • 7
      Plasmatic  commented on Aug. 2, 2020, 11:58 a.m.

      It wasn't meant to be hard.