You are given $$$n$$$ integers, where $$$n$$$ is an even number. Determine if they can be paired into $$$\frac{n}{2}$$$ pairs such that the sums of the two numbers in each pair are equal for all pairs.
In the first line, there is an integer $$$T$$$, the number of test cases.
For each case, there is a line with an integer $$$n$$$, followed by a line with the $$$n$$$ integers $$$a_1, \ldots, a_n$$$ that need to be paired.
For each case, if the numbers can be paired, write a line with "SI". Otherwise, write a line with "NO".
$$$1 \leq T \leq 100$$$
$$$4 \leq n \leq 10^5$$$, $$$n$$$ is an even number, the sum of $$$n$$$ for all cases is less than $$$5 \cdot 10^5$$$
$$$-10^8 \leq a_i \leq 10^8$$$ for $$$1 \leq i \leq n$$$
40 points: $$$n = 6$$$, $$$T \leq 30$$$
50 points: $$$n \leq 1000$$$, the sum of $$$n$$$ for all cases is less than $$$5000$$$
10 points: No additional restrictions
3 4 -2 1 -1 2 6 2 4 0 6 3 5 8 1 1 1 1 1 1 1 1
SI NO SI
Given an $$$a_0$$$, we define $$$a_{n+1} = \left \lfloor{\frac{a_n + a_n'}{2}}\right \rfloor$$$ where $$$a'$$$ is the number obtained by reversing the decimal representation of $$$a$$$ (for example, $$$1045' = 5401$$$) and $$$\left \lfloor{a}\right \rfloor$$$ is the largest integer less than or equal to $$$a$$$. Given $$$a_0$$$, what is the first $$$a_n$$$ that is a palindrome? (A number is a palindrome if its decimal representation reads the same forwards and backwards, that is, $$$a_n = a_n'$$$). If no $$$a_n$$$ is a palindrome, write "Que complicado!".
The first line indicates an integer $$$t$$$, the number of cases. In each of the following $$$t$$$ lines, there is an integer, the $$$a_0$$$ for the corresponding case.
For each case, write the first $$$a_n$$$ that is a palindrome, or if there is none, write "Que complicado!" without the quotes.
10 points: $$$t = 1000$$$ and $$$ 0 \leq a_0 \lt 1000$$$
30 points: $$$t = 10000$$$ and $$$0 \leq a_0 \lt 100000$$$
60 points: $$$t = 10000$$$ and $$$0 \leq a_0 \lt 1000000000$$$
4 8 45 245 10196087
8 44 393 Que complicado!
There is a grid with $$$n \times m$$$ cells (arranged in $$$n$$$ rows and $$$m$$$ columns). Initially, each cell contains the number $$$0$$$.
There are $$$q$$$ operations performed, where each operation consists of replacing the number written in each of the cells of a given row or column with a number $$$x$$$.
Output the sum of the numbers in the grid after performing the $$$q$$$ operations.
The input begins with a line containing the number of cases $$$T$$$.
Each case starts with a line containing three integers $$$n, m, q$$$. This is followed by $$$q$$$ lines, each containing a character $$$c_i$$$, which is "F" if the operation is on a row and "C" if it is on a column, an integer $$$a_i$$$, which indicates the row or column on which the operation is applied, and an integer $$$x_i$$$, the number to be written.
For each case, print a line with the sum of all the numbers written in the grid after performing the $$$q$$$ operations.
$$$1 \leq T \leq 500$$$
$$$1 \leq n, m, q \leq 5 \cdot 10^5$$$, the sum of $$$n$$$, the sum of $$$m$$$, and the sum of $$$q$$$ for all cases are all less than $$$3 \cdot 10^6$$$.
For operations where $$$c_i = F$$$, $$$1 \leq a_i \leq n$$$. For operations where $$$c_i = C$$$, $$$1 \leq a_i \leq m$$$.
$$$0 \leq x_i \leq 10^6$$$ for $$$i = 1, \ldots, q$$$.
14 points: $$$n, m, x_i, q \leq 1000$$$, the sum of $$$n \cdot m + q \cdot (n + m)$$$ for all cases is less than $$$5 \cdot 10^6$$$.
28 points: $$$n, m, x_i \leq 1000$$$, the sum of $$$n \cdot m$$$ for all cases is less than $$$5 \cdot 10^6$$$.
11 points: $$$n = 1$$$.
22 points: $$$x_i = 1$$$ for $$$i = 1, \ldots, q$$$.
25 points: No additional restrictions.
4 2 2 3 F 1 1 C 1 2 C 2 3 3 4 4 F 1 2 F 2 4 C 3 3 F 1 5 1 1 1 F 1 0 1 500000 1 F 1 1000000
10 38 0 500000000000
María has found a new hobby, building towers with disks. María has disks of $$$n$$$ different colors. For the $$$i$$$-th color, she has $$$a_i$$$ disks. She wants to build towers by stacking disks, but she only likes a set of towers if it meets the following conditions:
- All disks are used. - For each tower, the sequence of colors from top to bottom is the same as from bottom to top. - All towers are of equal height.
What is the minimum number of towers that María will have to build to achieve a set of towers that she likes?
The first line contains a number $$$t$$$ which is the number of cases.
The following $$$t$$$ cases each consist of the first line containing the number $$$n$$$ of colors for the case. The next line contains $$$n$$$ integers, where the $$$i$$$-th integer indicates the number of pieces of the $$$i$$$-th color.
For each case, print a single number: the minimum number of towers that María can build to create a set that she likes.
$$$ 1 \leq t \leq 100$$$
$$$ 1 \leq n \leq 10000$$$
$$$ 1 \leq a_i \leq 1000000000$$$
The sum of the $$$a_i$$$ for each case is $$$\leq 1000000000$$$
8 points: All $$$a_i$$$ are even
16 points: All $$$a_i$$$ are even except possibly one
9 points: $$$n \leq 2$$$
29 points: The sum of the $$$a_i$$$ for each case is $$$\leq 20000$$$
38 points: No additional restrictions
2 1 15 3 2 5 3
1 2
Election season has arrived in the town, and as every four years, the mayor wants to fix the public infrastructure a couple of months beforehand. This way, the city looks splendid on election day and gains the support of undecided voters.
For this election, he has decided to focus on the crosswalks. Over the years, their paint has deteriorated, so they need to be repainted. Some lines disappear completely, while others only partially... Additionally, it should be noted that after several repaints, it is likely that we will have a large number of lines, completely scattered, with different shades of faded white, which do not look very aesthetic.
But this will come to an end. The mayor has decided that he wants to repaint all the crosswalks in such a way that they all look nice. A nice crosswalk verifies the following characteristics:
As an intern in the urban planning department of the town hall, the mayor has entrusted you with the task of deciding what width the lines should have for each crosswalk to be nice.
The input will start with a number $$$T$$$, the number of crosswalks we are going to paint.
Each crosswalk will begin with two numbers $$$n$$$ and $$$k$$$, the number of old visible lines in the section of road we want to paint and the maximum number of lines we are willing to paint in the new crosswalk, respectively.
Following this, there will be $$$n$$$ pairs of numbers $$$a_0$$$ $$$l_0$$$ $$$a_1$$$ $$$l_1$$$ $$$\ldots$$$ $$$a_{n-1}$$$ $$$l_{n-1}$$$. The $$$i$$$-th pair indicates the height at which the old line $$$i$$$ is located and the width of that line, respectively.
For each crosswalk, an integer will be written on a separate line, indicating the maximum width that its lines can have for it to be nice.
$$$T \leq 80$$$
$$$1 \leq n \leq 10^5$$$
$$$1 \leq k \leq 10^9$$$
$$$1 \leq a_i \leq 5 \cdot 10^8$$$, $$$a_i \neq a_j$$$ for all $$$i \neq j$$$
$$$1 \leq l_i \leq 5 \cdot 10^8$$$
15 points: $$$k \leq n \leq 100$$$, $$$a_i \leq 1000$$$, $$$l_i = 1$$$, the sum of the $$$n$$$ in all cases is less than $$$5000$$$
27 points: $$$\frac{\max(a_i+l_i)}{10} \leq k$$$, the sum of the $$$n$$$ in all cases is less than $$$10^6$$$
35 points: $$$l_i = 1$$$, the sum of the $$$n$$$ in all cases is less than $$$10^6$$$
23 points: No additional restrictions, the sum of the $$$n$$$ in all cases is less than $$$1500000$$$
3 3 2 1 1 4 1 10 1 5 3 2 1 5 1 9 1 13 1 11 1 2 2 3 3 2 2
4 4 2
A company sells gold cubes, or at least that's what they call cubes filled with dirt that contain gold nuggets. To be precise, in the fine print, it specifies that each cube contains at least 100 milligrams of gold. Furthermore, they also claim that there is a possibility for the buyer to make money, as there are cubes that contain gold worth more than the price at which they are sold. The milligram of gold is valued at 5 cents, and the company sells its cubes at a price of $$$V$$$ euros.
The nuggets are categorized into 3 categories, each of which we assume has the same average weight:
Calculate the maximum possible profit, in cents, that the company can achieve, respecting the following conditions:
It is guaranteed that in the cases, a solution can always be found with a profit $$$\ge$$$ 0.
The first line contains an integer $$$T$$$, indicating the number of cases.
For each case, the first line contains the integer $$$V$$$.
The second line contains the integers $$$A, B, C$$$.
The third line contains the integers $$$P_1, P_2, P_3$$$.
Print for each case a line with the maximum possible profit in cents.
$$$1 \le T \le 20$$$
$$$1 \le V \le 1000$$$
$$$1 \le A \lt B \lt C \le 100$$$
$$$1 \le P_1 + P_2 + P_3 \le 180$$$
17 points: $$$A = 1; \ B = 2; \ C = 50; \ P_1, P_3 \gt 0; \ P_2 = 0$$$
20 points: $$$A = 10; \ B = 20; \ C = 50$$$
21 points: $$$1 \le P_1 + P_2 + P_3 \le 15$$$
42 points: No additional restrictions.
2 9 10 20 30 30 0 0 10 1 2 25 1 0 12
350 495