Rock-paper-scissors

You probably know about the rock-paper-scissors game, where two players
choose among rock, paper and scissors, and rock beats scissors, paper
beats rock, and scissors beats paper. If both oponents choose the same,
the game is tied. You are going to play several rounds, and you will
earn two points for every round that you win, and one point for every
tie.

Your oponent has decided to write all his decisions on paper before the
start of the game, and he will follow those decisions no matter what.
However, you cheated and could read all his decisions. To compensate for
such a huge advantatge, you decide to play between r₁ and r₂ rocks,
between p₁ and p₂ papers, and between s₁ and s₂ scissors. Under those
restrictions, can you maximize the points that you will earn?

Input

Let r, p and s be respectively the number of rocks, papers and scissors
of your oponent. Input consists of several cases, each with r, p and s,
followed by r₁, r₂, p₁, p₂, s₁ and s₂. You can assume r₁ ≤ r₂, p₁ ≤ p₂,
s₁ ≤ s₂, and r₁ + p₁ + s₁ ≤ r + p + s ≤ r₂ + p₂ + s₂ ≤ 10⁸.

Output

For every case, print the maximum number of points that you can earn.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:16:38.706Z

© Jutge.org, 2006–2026.
https://jutge.org
