Lazy Bob has $$$N$$$ ($$$1 ≤ N ≤ 1,000$$$) robot friends, each with their own height $$$h_i$$$ ($$$1 ≤ h_i ≤ 10^6$$$). Bob wonders, if he stacks all of the robot friends on top of each other to make one tall robot, how tall will that mega-robot be? Because he has so many robot friends, he needs your help to complete this task.
Line 1: One integer, $$$N$$$. Line 2: $$$N$$$ space-separated integers $$$h_i$$$.
Line 1: One integer representing the height of the mega-robot formed out of all $$$N$$$ stacked robot friends.
5 7 2 12 4 8
33
$$$1 ≤ N ≤ 1,000$$$
$$$1 ≤ h_i ≤ 10^6$$$
If Bob stacks all 5 of his robot friends together, the height of the resulting mega-robot would be $$$7 + 2 + 12 + 4 + 8 = 33$$$
March 7th (the person) is very excited about her birthday, which is on March 7th (the day). Thus, she wants to know the dates for when her birthday occurs between year $$$x$$$ and $$$y$$$ ($$$1 \le x \le y \le 10^5$$$). Each date should be formatted as follows: day of the month, month, year (without the commas).
The first line will contain two integers $$$x$$$ and $$$y$$$ ($$$1 \le x \le y \le 10^5$$$), denoting that March 7th wants you to find all occurrences of her birthday in the years $$$x$$$, $$$x + 1$$$, $$$\dots$$$, $$$y$$$.
Each line of the output should contain a string representing the date of one of March 7th's birthdays that occur between year $$$x$$$ and year $$$y$$$ formatted as specified above. Each birthday date should appear exactly once and be outputted in chronological order (earlier dates should be outputted before later dates).
2023 2024
7 March 2023 7 March 2024
Lazy Bob has created a machine learning model which receives one number as the input and outputs that number + 1 (a very interesting model, as you can see).
He has a list of $$$N$$$ ($$$1 ≤ N ≤ 10,000$$$) expected outputs $$$e_i$$$ and actual outputs $$$a_i$$$ ($$$1 ≤ e_i, a_i ≤ 10^9$$$), and he wants to find out the accuracy of his model. If an actual output is within $$$K$$$ ($$$0 ≤ K ≤ 100,000$$$) of its corresponding expected output, he counts it as the same (his model is not that good).
Output the model's accuracy as a percentage to the nearest integer (for example, if 8 out of 12 cases work as expected, that would be considered an accuracy of 67%) but do NOT include the percent sign in your answer. Check the Notes section if this is unclear.
Line 1: Two space-separated integers, $$$N$$$ and $$$K$$$.
Line 2…$$$N+1$$$: 2 space-separated integers $$$e_i$$$ and $$$a_i$$$.
Line 1: A percentage representing Bob's model's accuracy (to the nearest integer). It is guaranteed that the accuracy will never be < 0.01 away from the middle of two integers.
5 3 3 6 7 3 1 10 8 7 11 11
60
$$$1 ≤ N ≤ 10,000$$$
$$$0 ≤ K ≤ 100,000$$$
$$$1 ≤ a_i, e_i ≤ 10^9$$$
3 out of the 5 output pairs are within K of each other, which is why the accuracy is ⅗*100% = 60%. Drop the percent sign to get an answer of 60.
Maya wants to organize the training data for her machine-learning model. There are $$$N$$$ files that she can use, and each file has a size of $$$s_i$$$ bits. Her computer has a limited amount of storage, so she can only allocate $$$X$$$ bits toward storing all of the training data.
What is the maximum number of files that she can use for her model?
Line 1: Two integers, $$$N$$$ and $$$X$$$. Lines 2 ... $$$N+1$$$: 1 space-separated integer $$$s_i$$$ representing the $$$i$$$th file's size in bits.
Line 1: One integer representing the maximum number of files that Maya can use.
5 34 14 25 47 11 6
3
6 18 2 5 6 4 13 1
5
$$$1 ≤ N ≤ 100,000$$$
$$$1 ≤ s_i ≤ 10^9$$$
$$$1 ≤ X ≤ 10^9$$$
Tanner is speedrunning the hit video game The Legend of Zelda: Tears of the Kingdom, where his goal is to beat the game as fast as possible. To keep track of his progress, he creates splits for each important objective in the run.
Tanner wants to know his improvement between runs for certain splits. Given $$$N$$$ different runs composed of $$$K$$$ splits, with $$$t_i$$$ being the time in seconds for each split, for each of $$$Q$$$ different queries for a certain split $$$s$$$, please output the maximum improvement between any two times for a given split.
Line $$$1$$$: Three space separated integers $$$N$$$,$$$K$$$,$$$Q$$$
Lines $$$2…N+1$$$: $$$K$$$ space separated integers $$$t_1...t_K$$$
Lines $$$N+2…N+Q+1$$$: An integer, $$$s$$$
Lines $$$1…Q$$$: An integer representing the maximum improvement between any two times for split $$$s$$$.
4 5 3 1 3 4 6 9 2 4 5 7 8 1 2 6 9 10 1 2 3 4 7 2 4 1
2 5 1
$$$1 \lt N,K ≤700$$$
$$$1≤t_i≤10^9, t_i \lt t_i+1$$$
$$$1≤Q≤10^5$$$
$$$1≤s≤K$$$
For the second split, the maximum improvement is either between runs 2 and 3 or between runs 2 and 4, which results in an improvement of 4-2=2 seconds.
For the fourth split, the maximum improvement is between runs 3 and 4, which results in an improvement of 9-4=5 seconds.
For the first split, the maximum improvement is between either runs 1 and 2, between runs 2 and 3, or between runs 2 and 4, which results in an improvement of 2-1=1 second.
Stelle is in Xianzhou Luofu and needs to call a taxi. However, before one can call a taxi, they must solve a simple puzzle.
The puzzle consists of a ring with $$$n$$$ ($$$1 \le n \le 10^9$$$) points on its circumference. These points are labelled from $$$1 \dots n$$$. On these points, there are three movable objects. In one move, Stelle can choose any one of these movable objects and move it either one point counterclockwise or one point clockwise, and the taxi will be called once all objects reach the same position.
Since Stelle is in a hurry, she now wants you to find the minimum number of moves she needs to call the taxi.
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^9$$$), denoting the number of points on the circumference on the circle.
The second line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$1 \le a, b, c, \le n$$$), denoting that the first movable object is at point $$$a$$$, the second one is at point $$$b$$$, and the third one is at point $$$c$$$.
Output a single integer denoting the minimum number of moves needed to move all of the movable objects to the same point.
6 1 3 5
4
5 1 1 5
1
Karel the Robot is given a string $$$S$$$ and $$$Q$$$ queries. The $$$i$$$th query consists of integers $$$L_i$$$ and $$$R_i$$$, with $$$1≤L_i≤R_i≤|S|$$$. Help Karel find the number of substrings of the same character in $$$S[L_i,R_i]$$$. For example, $$$aa$$$ contains one substring of the same character, $$$aba$$$ contains three, and $$$abbcccddaa$$$ contains five.
Line 1: One string, $$$S$$$.
Line 2: One integer, $$$Q$$$.
Lines 3…$$$Q+2$$$: Line $$$i+2$$$ contains integers $$$L_i$$$ and $$$R_i$$$, separated by a space.
Lines 1…$$$Q$$$: Line $$$i$$$ contains the answer to the $$$i$$$th query, more specifically the number of substrings of the same character in $$$S[L_i,R_i]$$$.
aabcccab 8 1 1 1 2 1 3 1 4 1 5 1 8 2 4 4 6
1 1 2 3 3 5 3 1
$$$1≤S≤10^5$$$
$$$1≤Q≤10^5$$$
One-indexing is used in this problem. For example, if $$$S$$$=$$$aabcccab$$$, then $$$S[3,6]$$$=$$$bccc$$$, not $$$ccca$$$.
The substrings that the inputs correspond to are $$$a$$$,$$$aa$$$,$$$aab$$$,$$$aabc$$$,$$$aabcc$$$,$$$aabcccab$$$,$$$abc$$$, and $$$ccc$$$, respectively. For instance, the answer to the $$$5$$$th query is 3 because $$$aabcc$$$ contains three substrings of the same character: $$$aa$$$, $$$b$$$, and $$$cc$$$.
Will has been transported to another dimension and is unable to escape on his own! Fortunately, since he is a brilliant computer scientist, Will has found a way to communicate with his mother, Joyce, by building figures resembling a binary tree using LED lights connected by metal rods. The initial LED lights (up to two) are connected to a power source by metal rods, and more LED lights can stem from these, with at most two rods emanating from each light, one to the left and one to the right.
Will has used $$$N$$$ lights numbered $$$1-N$$$. Joyce has figured out that the depth $$$D$$$ of an LED light with no rods emanating from it, called an "end light," corresponds to the $$$D$$$th letter of the alphabet. The power source has a depth of 0; light $$$1$$$ emanates from it to the left, and light $$$2$$$ emanates from it to the right. The lights should be read from left to right, with all the end lights emanating from a given left rod being read before any of the end lights from the corresponding right rod. Given the information for each light, help Joyce decode Will's message so she can locate her son!
Line $$$1$$$: An integer $$$N$$$
Lines $$$2…N$$$+1: $$$N$$$ lines denoting, in order, the information for the $$$N$$$ lights. Each line contains two integers: the number of the left light and the right light emanating from it (or $$$0$$$ if there is no light).
Line $$$1$$$: An all-uppercase string representing the decoded message.
5 3 4 0 0 0 0 0 5 0 0
BCA
$$$2 \lt = N \lt = 10^5$$$
Kafka wants to cause some trouble at the Xianzhou Luofu. She is currently at the Ambrosial Arbor, which is a large tree with $$$n$$$ ($$$2 \le n \le 10^5$$$). In the tree, node $$$i$$$ has an explosion value of $$$a_i$$$ ($$$1 \le a_i \le 10^8$$$), and the edges all have weight $$$1$$$. If a simple cycle is created in the tree, it will explode with a magnitude of the sum of edge weights on the cycle. In order to carry out her terrorism, Kafka will add an edge between two nodes $$$u$$$ and $$$v$$$ with weight $$$a_u + a_v$$$, thus creating a simple cycle and exploding the tree. Note that $$$u \ne v$$$.
As a wanted terrorist, Kafka wants to cause as large an explosion as possible, so please tell her the largest magnitude explosion that she could cause by adding any edge.
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^8$$$).
The third line contains $$$n - 1$$$ integers $$$p_2, p_3, \ldots, p_n$$$ ($$$1 \le p_i \lt i$$$), meaning that there is an edge between node $$$p_i$$$ and node $$$i$$$, and node $$$p_i$$$ is a parent of node $$$i$$$.
The output should consist of a single integer denoting the largest magnitude of an explosion that Kafka can create.
5 1 2 3 3 3 1 1 2 4
10
5 10 1 1 1 1 1 1 3 4
14
You are given $$$N$$$ groups of robots, with the $$$i$$$th group having the coordinate $$$X_i$$$ on a number line. Also, the number of robots in the $$$i$$$th group is $$$A_i$$$. Not all groups of robots have a distinct coordinate $$$X_i$$$. If two groups of robots share the same $$$X_i$$$, they are combined into one larger group. Among all points on the number line with integer coordinate $$$Y$$$ such that $$$Y$$$ is different from all $$$X_i$$$, the following quantity has a minimum value:
The absolute difference between the sum of the distances from $$$Y$$$ to the robots left of $$$Y$$$ and the sum of the distances from $$$Y$$$ to the robots right of $$$Y$$$.
Find this minimum value.
Line 1: One integer, $$$N$$$.
Line 2…$$$N+1$$$: Line $$$i+1$$$ contains two integers, $$$X_i$$$ and $$$A_i$$$, separated by a space.
Line 1: One integer, representing the minimum possible value of the quantity:
The absolute difference between the sum of the distances from $$$Y$$$ to the robots left of $$$Y$$$ and the sum of the distances from $$$Y$$$ to the robots right of $$$Y$$$.
3 1 5 6 4 9 3
4
5 7 6 5 8 7 2 10 7 8 7
42
$$$1≤N≤10^5.$$$
$$$1≤X_i≤10^9.$$$
$$$1≤A_i≤10^4.$$$
If we choose $$$Y=5$$$, then only the input $$$1 5$$$ is to the left of $$$Y$$$, so "the sum of the distances from $$$Y$$$ to the robots left of $$$Y$$$" evaluates to $$$5⋅Y-1=20$$$. Similarly, "the sum of the distances from $$$Y$$$ to the robots right of $$$Y$$$" evaluates to $$$4⋅6-Y+3⋅9-Y=16$$$. The difference between $$$20$$$ and $$$16$$$ is $$$4$$$, so that is the output.