summaryrefslogtreecommitdiff
path: root/code-jam22/round1/3d-printing.jl
blob: c003a4b2648448bfeaaff290333ec847ab37b752 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
cases = parse(Int, readline())

for case = 1:cases
    colors = reduce(hcat, map(1:3) do ()
        parse.(Int, split(readline()))
    end)
    print("Case #", case, ": ")
    m = map(1:4) do c minimum(colors[c, :]) end
    over = sum(m) - 1_000_000
    if over < 0
        println("IMPOSSIBLE")
    else
        i = 1
        while over > 0
            if m[i]  over
                m[i] -= over
                break
            else
                over -= m[i]
                m[i] = 0
                i += 1
            end
        end
        println(join(m, ' '))
    end
end