There is a new conveyor belt sushi restaurant in town. Plates of sushi travel around the restaurant on a raised conveyor belt and customers choose what to eat by removing plates.
Each red plate of sushi costs \(\$3\), each green plate of sushi costs \(\$4\), and each blue plate of sushi costs \(\$5\).
   Â
   Â
Your job is to determine the cost of a meal, given the number of plates of each colour chosen by a customer.
The first line of input contains a non-negative integer, \(R\), representing the number of red plates chosen. The second line contains a non-negative integer, \(G\), representing the number of green plates chosen. The third line contains a non-negative integer, \(B\), representing the number of blue plates chosen.
Output the non-negative integer, \(C\), which is the cost of the meal in dollars.
0
2
4
28
This customer chose \(0\) red plates, \(2\) green plates, and \(4\) blue plates. Therefore, the cost of the meal in dollars is \(0 \times 3 + 2 \times 4 + 4 \times 5 = 28\).
Dusa eats Yobis, but only Yobis of a certain size.
If Dusa encounters a Yobi that is smaller than itself, it eats the Yobi, and absorbs its size. For example, if Dusa is of size \(10\) and it encounters a Yobi of size \(6\), Dusa eats the Yobi and expands to size \(10+6=16\).
If Dusa encounters a Yobi that is the same size as itself or larger, Dusa runs away without eating the Yobi.
Dusa is currently facing a line of Yobis and will encounter them in order. Dusa is guaranteed to eventually encounter a Yobi that causes it to run away. Your job is to determine Dusa’s size when this happens.
   Â
The first line of input contains a positive integer, \(D\), representing Dusa’s starting size.
The remaining lines of input contain positive integers representing the sizes of the Yobis in order.
Output the positive integer, \(R\), which is Dusa’s size when it eventually runs away.
5
3
2
9
20
22
14
19
Dusa is large enough to eat the Yobi of size \(3\). This brings Dusa’s size to \(8\). Dusa is large enough to eat the Yobi of size \(2\). This brings Dusa’s size to \(10\). Dusa is large enough to eat the Yobi of size \(9\). This brings Dusa’s size to \(19\). The Yobi of size \(20\) causes Dusa to run away.
10
10
3
5
10
The Yobi of size \(10\) causes Dusa to run away, leaving its size unchanged.
After completing a competition, you are struck with curiosity. How many participants were awarded bronze level?
Gold level is awarded to all participants who achieve the highest score. Silver level is awarded to all participants who achieve the second highest score. Bronze level is awarded to all participants who achieve the third highest score.
Given a list of all the scores, your job is to determine the score required for bronze level and how many participants achieved this score.
The first line of input contains a positive integer, \(N\), representing the number of participants.
Each of the next \(N\) lines of input contain a single integer representing a participant’s score.
Each score is between \(0\) and \(75\) (inclusive) and there will be at least three distinct scores.
The following table shows how the available \(15\) marks are distributed:
Marks | Description | Bound |
---|---|---|
\(6\) | The scores are distinct and the number of participants is small. | \(N \leq 50\) |
\(7\) | The scores might not be distinct and the number of participants is small. | \(N \leq 50\) |
\(2\) | The scores might not be distinct and the number of participants could be large. | \(N \leq 250\,000\) |
Output a non-negative integer, \(S\), and a positive integer, \(P\), separated by a single space, where \(S\) is the score required for bronze level and \(P\) is how many participants achieved this score.
4
70
62
58
73
62 1
The score required for bronze level is \(62\) and one participant achieved this score.
8
75
70
60
70
70
60
75
70
60 2
The score required for bronze level is \(60\) and two participants achieved this score.
As Alex is typing, their keyboard is acting strangely. Two letter keys are causing trouble:
One letter key displays the same wrong letter each time it is pressed. Alex calls this key the silly key. Oddly, Alex never actually tries to type the wrong letter displayed by the silly key.
Another letter key doesn’t display anything when it is pressed. Alex calls this key the quiet key.
Alex presses the silly key at least once but they don’t necessarily press the quiet key.
Your job is to determine the troublesome keys and the wrong letter that is displayed. Luckily, this is possible because Alex never presses the silly key immediately after pressing the quiet key and Alex never presses the quiet key immediately after pressing the silly key.
There will be two lines of input. The first line of input represents the \(N\) keys Alex presses on the keyboard. The second line of input represents the letters displayed on the screen.
Both lines of input will only contain lowercase letters of the alphabet.
The following table shows how the available \(15\) marks are distributed.
Marks | Description | Bound |
---|---|---|
\(3\) | The quiet key is not pressed. A small number of keys are pressed. | \(N \leq 50\) |
\(3\) | The first troublesome key pressed is the silly key. A small number of keys are pressed. | \(N \leq 50\) |
\(5\) | The first troublesome key pressed may be the silly key or the quiet key. A small number of keys are pressed. | \(N \leq 50\) |
4 | The first troublesome key pressed may be the silly key or the quiet key. A large number of keys are pressed. | \(N \leq 500\,000\) |
There will be two lines of output.
On the first line, output the letter corresponding to the silly key and the wrong letter displayed on the screen when it is pressed, separated by a single space.
On the second line, output the letter corresponding to the quiet key
if it is pressed. Output the dash character (-
) if the
quiet key is not pressed.
forloops
fxrlxxps
o x
-
The letter corresponding to the silly key was the letter
o
. Each time it was pressed, the wrong letter
x
was displayed. The quiet key was not pressed.
forloops
fxrlxxp
o x
s
The letter corresponding to the silly key was the letter
o
. Each time it was pressed, the wrong letter
x
was displayed. The quiet key corresponds to the letter
s
which was not displayed.
forloops
frlpz
s z
o
The letter corresponding to the silly key was the letter
s
. Each time it was pressed, the wrong letter
z
was displayed. The quiet key corresponds to the letter
o
which was not displayed.
There is a wildly popular new harvest simulation game called Harvest Waterloo. The game is played on a rectangular pumpkin patch which contains bales of hay and pumpkins of different sizes. To begin the game, a farmer is placed at the location of a pumpkin.
The farmer harvests all pumpkins they can reach by moving left, right, up, and down throughout the patch. The farmer cannot move diagonally. The farmer can also not move through a bale of hay nor move outside of the patch.
Your job is to determine the total value of all the pumpkins harvested by the farmer. A small pumpkin is worth \(\$1\), a medium pumpkin is worth \(\$5\), and a large pumpkin is worth \(\$10\) dollars.
The first line of input is an integer \(R > 0\) which is the number of rows within the patch.
The second line of input is an integer \(C > 0\) which is the number of columns within the patch.
The next \(R\) lines describe the
patch. Each line will contain \(C\)
characters and each character will either represent a pumpkin size or a
bale of hay: S
for a small pumpkin, M
for a
medium pumpkin, L
for a large pumpkin, or *
for a bale of hay.
The next line of input is an integer \(A\) where \(0 \leq A < R\), and the last line of input is an integer \(B\) where \(0 \leq B < C\). Row \(A\) and column \(B\) is the starting location of the farmer and the top-left corner of the patch is row \(0\) and column \(0\).
The following table shows how the available \(15\) marks are distributed:
Marks | Description | Bound |
---|---|---|
\(1\) | The patch is small and there are no bales of hay. | \(R \times C \leq 100\) |
\(4\) | The patch is small and the bales of hay divide the entire patch into rectangular areas. | \(R \times C \leq 100\) |
\(5\) | The patch is small and the bales of hay can be anywhere. | \(R \times C \leq 100\) |
\(5\) | The patch is large and the bales of hay can be anywhere. | \(R \times C \leq 100\,000\) |
Output the integer, \(V\), which is the total value in dollars of all the pumpkins harvested by the farmer.
6
6
**LMLS
S*LMMS
S*SMSM
******
LLM*MS
SSL*SS
5
1
37
Starting at row 5 and column 1, the farmer can reach the 6 pumpkins in the highlighted area. They harvest 2 small pumpkins, 1 medium pumpkin, and 3 large pumpkins. The total value in dollars of this harvest is \(2 \times 1 + 1 \times 5 + 3 \times 10 = 37\).
6
6
**LMLS
S*LMMS
S*SMSM
***SLL
LLM*MS
SSL*SS
2
4
88
Starting at row \(2\) and column \(4\), the farmer can reach the \(19\) pumpkins in the highlighted area. They harvest \(8\) small pumpkins, \(6\) medium pumpkin, and \(5\) large pumpkins. The total value in dollars of this harvest is \(8 \times 1 + 6 \times 5 + 5 \times 10 = 88\).