text
stringlengths 0
801
|
---|
It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
|
For each test case, output a single integer: the maximum $\operatorname{MEX}$ of $a$ if you perform the operations optimally.
|
In the first test case, the $\operatorname{MEX}$ of $a$ is $4$ without performing any operations, which is the maximum.
|
In the second test case, the $\operatorname{MEX}$ of $a$ is $5$ without performing any operations. If we perform two operations both with $i=1$, we will have the array $a=[5,3,4,1,0,2]$. Then, the $\operatorname{MEX}$ of $a$ will become $6$, which is the maximum.
|
In the third test case, the $\operatorname{MEX}$ of $a$ is $0$ without performing any operations, which is the maximum.
|
This is the easy version of the problem. In the three versions, the constraints on $n$ and $m$ are different. You can make hacks only if all the versions of the problem are solved.
|
Pak Chanek is setting up internet connections for the village of Khuntien. The village can be represented as a connected simple graph with $n$ houses and $m$ internet cables connecting house $u_i$ and house $v_i$, each with a latency of $w_i$.
|
There are $p$ houses that require internet. Pak Chanek can install servers in at most $k$ of the houses. The houses that need internet will then be connected to one of the servers. However, since each cable has its latency, the latency experienced by house $s_i$ requiring internet will be the maximum latency of the cables between that house and the server it is connected to.
|
For each $k = 1,2,\ldots,n$, help Pak Chanek determine the minimum total latency that can be achieved for all the houses requiring internet.
|
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). The description of the test cases follows.
|
The first line of each test case contains three integers $n$, $m$, $p$ ($2 \le n \le 400$; $n-1 \le m \le 400$; $1 \le p \le n$) — the number of houses, the number of cables and the number of houses that need internet.
|
The second line of each test case contains $p$ integers $s_1, s_2, \ldots, s_p$ ($1 \le s_i \le n$) — the houses that need internet. It is guaranteed that all elements of $s$ are distinct.
|
The $i$-th of the next $m$ lines of each test case contains three integers $u_i$, $v_i$, and $w_i$ ($1 \le u_i < v_i \le n$; $1 \le w_i \le 10^9$) — the internet cable connecting house $u_i$ and house $v_i$ with latency of $w_i$. It is guaranteed that the given edges form a connected simple graph.
|
It is guaranteed that the sum of $n^3$ and the sum of $m^3$ do not exceed $10^8$.
|
For each test case, output $n$ integers: the minimum total latency that can be achieved for all the houses requiring internet for each $k = 1,2
|
This is the extreme version of the problem. In the three versions, the constraints on $n$ and $m$ are different. You can make hacks only if all the versions of the problem are solved.
|
Pak Chanek is setting up internet connections for the village of Khuntien. The village can be represented as a connected simple graph with $n$ houses and $m$ internet cables connecting house $u_i$ and house $v_i$, each with a latency of $w_i$.
|
There are $p$ houses that require internet. Pak Chanek can install servers in at most $k$ of the houses. The houses that need internet will then be connected to one of the servers. However, since each cable has its latency, the latency experienced by house $s_i$ requiring internet will be the maximum latency of the cables between that house and the server it is connected to.
|
For each $k = 1,2,\ldots,n$, help Pak Chanek determine the minimum total latency that can be achieved for all the houses requiring internet.
|
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.
|
The first line of each test case contains 3 integers $n$, $m$, $p$ ($2 \le n \le 2 \cdot 10^5$; $n-1 \le m \le 2 \cdot 10^5$; $1 \le p \le n$) — the number of houses, the number of cables, and the number of houses that need internet.
|
The second line of each test case contains $p$ integers $s_1, s_2, \ldots, s_p$ ($1 \le s_i \le n$) — the houses that need internet. It is guaranteed that all elements of $s$ are distinct.
|
The $i$-th of the next $m$ lines of each test case contains three integers $u_i$, $v_i$, and $w_i$ ($1 \le u_i < v_i \le n$; $1 \le w_i \le 10^9$) — the internet cable connecting house $u_i$ and house $v_i$ with latency of $w_i$. It is guaranteed that the given edges form a connected simple graph.
|
It is guaranteed that the sum of $n$ and the sum of $m$ do not exceed $2 \cdot 10^5$.
|
For each test case, output $n$ integers: the minimum total latency that can be achieved for all the houses requiring int
|
Ya vamos llegando a Péeeenjamoo ♫♫♫
|
There are $n$ families travelling to Pénjamo to witness Mexico's largest- ever "walking a chicken on a leash" marathon. The $i$-th family has $a_i$ family members. All families will travel using a single bus consisting of $r$ rows with $2$ seats each.
|
A person is considered happy if:
|
* Another family member is seated in the same row as them, or * They are sitting alone in their row (with an empty seat next to them).
|
Determine the maximum number of happy people in an optimal seating arrangement. Note that everyone must be seated in the bus.
|
It is guaranteed that all family members will fit on the bus. Formally, it is guaranteed that $\displaystyle\sum_{i=1}^{n}a_i \le 2r$.
|
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows.
|
The first line of each test case contains two integers $n$ and $r$ ($1 \le n \le 100$; $1 \le r \le 500$) — the number of families and the number of rows in the bus.
|
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10$) — the number of family members in each family.
|
For each test case, output the maximum number of happy people in an optimal seating arrangement.
|
In the first test case, the two members of the first family can sit together in the first row, while the two members of the second family can sit together in the second row. The remaining member of the second family can sit in the third row along with a member of the third family. This seating arrangement is shown below, where the $4$ happy people are colored green.
|
$\color{green}{1}$| $\color{green}{1}$ ---|--- $\color{green}{2}$| $\color{green}{2}$ $2$| $3$ In the second test case, a possible seating arrangement with $6$ happy people is shown below.
|
$\color{green}{3}$| $\color{green}{3}$ ---|--- $\color{green}{1}$| $\color{green}{1}$ $\color{green}{2}$| $\color{green}{2}$ In the third test case, a possible seating ar
|
We all steal a little bit. But I have only one hand, while my adversaries have two.
|
Álvaro Obregón
|
Álvaro and José are the only candidates running for the presidency of Tepito, a rectangular grid of $2$ rows and $n$ columns, where each cell represents a house. It is guaranteed that $n$ is a multiple of $3$.
|
Under the voting system of Tepito, the grid will be split into districts, which consist of any $3$ houses that are connected$^{\text{∗}}$. Each house will belong to exactly one district.
|
Each district will cast a single vote. The district will vote for Álvaro or José respectively if at least $2$ houses in that district select them. Therefore, a total of $\frac{2n}{3}$ votes will be cast.
|
As Álvaro is the current president, he knows exactly which candidate each house will select. If Álvaro divides the houses into districts optimally, determine the maximum number of votes he can get.
|
$^{\text{∗}}$A set of cells is connected if there is a path between any $2$ cells that requires moving only up, down, left and right through cells in the set.
|
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.
|
The first line of each test case contains one integer $n$ ($3 \le n \le 10^5$; $n$ is a multiple of $3$) — the number of columns of Tepito.
|
The following two lines each contain a string of length $n$. The $i$-th line contains the string $s_i$, consisting of the characters $\texttt{A}$ and $\texttt{J}$. If $s_{i,j}=\texttt{A}$, the house in the $i$-th row and $j$-th column will select Álvaro. Otherwise if $s_{i,j}=\texttt{J}$, the house will select José.
|
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.
|
For each test case, output a single integer — the maximum number of districts Álvaro can win by optimally dividing the houses into districts.
|
The image below showcases the optimal arrangement of districts Álvaro can use for each test case in the example.
|
![](CD
|
You are given $n$ arrays $a_1$, $\ldots$, $a_n$. The length of each array is two. Thus, $a_i = [a_{i, 1}, a_{i, 2}]$. You need to concatenate the arrays into a single array of length $2n$ such that the number of inversions$^{\dagger}$ in the resulting array is minimized. Note that you do not need to count the actual number of inversions.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.