##### Canadian Computing Competition: 2000 Stage 1, Junior #4, Senior #2

A series of streams run down the side of a mountain. The mountainside is very rocky so the streams split and rejoin many times. At the foot of the mountain, several streams emerge as rivers. Your job is to compute how much water flows in each river.

At any given elevation there are streams, labelled to from left-to-right. As we proceed down the mountainside, one of the streams may split into a left fork and a right fork, increasing the total number of streams by , or two streams may rejoin, reducing the total number of streams by . After a split or a rejoining occurs, the streams are renumbered consecutively from left-to-right. There is always at least one stream and there are never more than streams.

#### Input Specification

The first line of input contains , the initial number of streams at some high altitude. The next lines give the flow in each of the streams from left-to-right. Proceeding down the mountainside, several split or rejoin locations are encountered. For each **split** location, there will be three lines of input.

- a line containing
`99`

(to indicate a split) - a line containing an integer, the number of the stream that is split
- a line containing an integer between and , the percentage of flow from the split stream that flows to the left fork. (The rest flows to the right fork)

For each **join** location, there will be two lines of input:

- a line containing
`88`

(to indicate a join) - a line containing an integer, the number of the stream that is rejoined with the stream to its right

The flow from both joined streams is combined. After the last split or join location will be:

- a single line containing
`77`

(to indicate end of input)

#### Output Specification

Your job is to determine how many streams emerge at the foot of the mountain and what the flow is in each. Your output is a sequence of real numbers, rounded to the nearest integer, giving the flow in rivers through .

#### Sample Input

```
3
10
20
30
99
1
50
88
3
88
2
77
```

#### Sample Output

`5 55`

## Comments

Not getting last test case right. Can someone help https://dmoj.ca/src/3567802

Getting all test cases right except for the last one. Can't find any issues in my code. Does anyone have any ideas?

When you multiply with the "percent" variable, it casted the value to an integer, which messes with your rounding in the end.

Nvm

When splitting or merging, left and right is based on your view of the mountain (i.e., the direction is not relative to the split).

I'm getting all of the cases right except for the index out of bounds error on the last one but I can't find anything wrong. Any ideas??

The first 3 cases got accepted, but I can't quite figure out what's wrong with the last one. Could someone help? (I use Python)

My submission

Line 29 - Integer divided by an integer returns integer, flooring the value before you intend to round it.

Getting all test cases right except for the last one. Can't find any issues in my code. Anyone have any ideas?

Edit: Found my issue

I have the same issue. How did you fix yours?

Edit: The problem was that, when a stream splits, the amount of water in it could be a decimal.

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

Getting first 3 cases right, however last 2 cases wrong and I can't seem to figure it out :/ Any ideas?

Edit: When adding (88), I messed up and made any number after the one joining take from one before instead of one after. My bad.