Snowball Fight

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Two people are having a fun snowball fight. The fight begins with both people throwing a snowball at each other at the same time. After the i-th person throws a snowball, it takes w_i seconds before they throw another. Every snowball that is thrown will hit the other person. If the i-th person is hit by at least h_i snowballs, they will give up. If both people give up at the same time, the fight is a tie. Otherwise, the remaining person is declared the winner. What will be the outcome of the fight?

Constraints

1 \le h_i, w_i \le 20

Input Specification

The input consists of two lines. The first line contains two space-separated integers h_1 and w_1. The second line contains two space-separated integers h_2 and w_2.

Output Specification

Output a single integer: 1 if the first person wins, 2 if the second person wins, or -1 if the fight is a tie.

Sample Input 1

2 3
2 4

Output for Sample Input 1

1

Explanation for Output for Sample Input 1

The first person is able to throw their second snowball after 3 seconds, forcing the second person to give up before they can throw their second snowball.

Sample Input 2

3 4
4 6

Output for Sample Input 2

-1

Explanation for Output for Sample Input 2

At 4 seconds, the first person throws their second snowball.
At 6 seconds, the second person throws their second snowball. At 8 seconds, the first person throws their third snowball.
At 12 seconds, both players throw another snowball. The first person is hit by 3 snowballs, and the second hit by 4, thus both give up at the same time.


Comments

There are no comments at the moment.