## Yard Sale

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M
Java 128M
PyPy 2 128M
PyPy 3 128M

Author:
Problem type

Over the weekend, Bob is going to a yard sale hosted by one of his neighbors. When he arrives, he notices that there is a long table that has items arranged on it in a row. Bob estimates the value of the items in dollars as in order.

To get rid of as many items as possible, Bob's neighbor sells in a very particular way. He will make Bob offers to sell all the items in the range for a price of dollars.

In order to maximize his profits, Bob has asked you to tell him which of the offers are profitable for him. For an offer to be profitable, the sum of the values in the range must be strictly greater than the price offered.

#### Input Specification

The first line of input will contain two space-separated integers, and .

The next line of input will contain space-separated integers, .

The next lines of input will each contain three space-separated integers, , , and .

#### Output Specification

For each query, output on a new line good if the offer is profitable for Bob and bad if it's not.

##### Subtask 2 [80%]

No further constraints.

#### Sample Input

3 3
5 1 6
1 2 3
1 3 13
2 3 7

#### Sample Output

good
bad

#### Explanation for Sample Output

For the first offer, the total value is dollars so Bob earns a profit if he pays dollars.

For the second offer, the total value is dollars so Bob loses money if he pays dollars.

For the third offer, the total value is dollars so Bob does not earn a profit if he pays dollars.