text stringlengths 0 801 |
|---|
The sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. |
For each test case output "YES" (without quotes) if Alex can take a shower for that given test case, and "NO" (also without quotes) otherwise. |
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes", and "Yes" will be recognized as a positive response). |
On the board Ivy wrote down all integers from $l$ to $r$, inclusive. |
In an operation, she does the following: |
* pick two numbers $x$ and $y$ on the board, erase them, and in their place write the numbers $3x$ and $\lfloor \frac{y}{3} \rfloor$. (Here $\lfloor \bullet \rfloor$ denotes rounding down to the nearest integer). |
What is the minimum number of operations Ivy needs to make all numbers on the board equal $0$? We have a proof that this is always possible. |
The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. |
The only line of each test case contains two integers $l$ and $r$ ($1 \leq l < r \leq 2 \cdot 10^5$). |
For each test case, output a single integer — the minimum number of operations needed to make all numbers on the board equal $0$. |
In the first test case, we can perform $5$ operations as follows: $$ 1,2,3 \xrightarrow[x=1,\,y=2]{} 3,0,3 \xrightarrow[x=0,\,y=3]{} 1,0,3 \xrightarrow[x=0,\,y=3]{} 1,0,1 \xrightarrow[x=0,\,y=1]{} 0,0,1 \xrightarrow[x=0,\,y=1]{} 0,0,0 .$$ |
In Berland, a bus consists of a row of $n$ seats numbered from $1$ to $n$. Passengers are advised to always board the bus following these rules: |
* If there are no occupied seats in the bus, a passenger can sit in any free seat; * Otherwise, a passenger should sit in any free seat that has at least one occupied neighboring seat. In other words, a passenger can sit in a seat with index $i$ ($1 \le i \le n$) only if at least one of the seats with indices $i-1$ or $i+1$ is occupied. |
Today, $n$ passengers boarded the bus. The array $a$ chronologically records the seat numbers they occupied. That is, $a_1$ contains the seat number where the first passenger sat, $a_2$ — the seat number where the second passenger sat, and so on. |
You know the contents of the array $a$. Determine whether all passengers followed the recommendations. |
For example, if $n = 5$, and $a$ = [$5, 4, 2, 1, 3$], then the recommendations were not followed, as the $3$-rd passenger sat in seat number $2$, while the neighboring seats with numbers $1$ and $3$ were free. |
The first line of input contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. |
The following describes the input test cases. |
The first line of each test case contains exactly one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of seats in the bus and the number of passengers who boarded the bus. |
The second line of each test case contains $n$ distinct integers $a_i$ ($1 \le a_i \le n$) — the seats that the passengers occupied in chronological order. |
It is guaranteed that the sum of $n$ values across all test cases does not exceed $2 \cdot 10^5$, and that no passenger sits in an already occupied seat. |
For each test case, output on a separate line: |
* "YES", if all passengers followed the recommendations; * "NO" otherwise. |
You may output the answer in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as a positive answer). |
The first test case is explained in the problem statement. |
You have $n$ rectangles, the $i$-th of which has a width of $a_i$ and a height of $b_i$. |
You can perform the following operation an unlimited number of times: choose a rectangle and a cell in it, and then color it. |
Each time you completely color any row or column, you earn $1$ point. Your task is to score at least $k$ points with as few operations as possible. |
Suppose you have a rectangle with a width of $6$ and a height of $3$. You can score $4$ points by coloring all the cells in any $4$ columns, thus performing $12$ operations. |
The first line contains an integer $t$ ($1 \le t \le 100$) — the number of test cases. The following are the descriptions of the test cases. |
The first line of each test case description contains two integers $n$ and $k$ ($1 \le n \le 1000, 1 \le k \le 100$) — the number of rectangles in the case and the required number of points. |
The next $n$ lines contain the descriptions of the rectangles. The $i$-th line contains two integers $a_i$ and $b_i$ ($1 \le a_i, b_i \le 100$) — the width and height of the $i$-th rectangle. |
It is guaranteed that the sum of the values of $n$ across all test cases does not exceed $1000$. |
For each test case, output a single integer — the minimum number of operations required to score at least $k$ points. If it is impossible to score at least $k$ points, output -1. |
Ksyusha decided to start a game development company. To stand out among competitors and achieve success, she decided to write her own game engine. The engine must support a set initially consisting of $n$ distinct integers $a_1, a_2, \ldots, a_n$. |
The set will undergo $m$ operations sequentially. The operations can be of the following types: |
* Insert element $x$ into the set; * Remove element $x$ from the set; * Report the $k$-load of the set. |
The $k$-load of the set is defined as the minimum positive integer $d$ such that the integers $d, d + 1, \ldots, d + (k - 1)$ do not appear in this set. For example, the $3$-load of the set $\\{3, 4, 6, 11\\}$ is $7$, since the integers $7, 8, 9$ are absent from the set, and no smaller value fits. |
Ksyusha is busy with management tasks, so you will have to write the engine. Implement efficient support for the described operations. |
The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases. |
The following lines describe the test cases. |
The first line contains an integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the initial size of the set. |
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_1 < a_2 < \ldots < a_n \le 2 \cdot 10^6$) — the initial state of the set. |
The third line contains an integer $m$ ($1 \le m \le 2 \cdot 10^5$) — the number of operations. |
The next $m$ lines contain the operations. The operations are given in the following format: |
* + $x$ ($1 \le x \le 2 \cdot 10^6$) — insert element $x$ into the set (it is guaranteed that $x$ is not in the set); * - $x$ ($1 \le x \le 2 \cdot 10^6$) — remove element $x$ from the set (it is guaranteed that $x$ is in the set); * ? $k$ ($1 \le k \le 2 \cdot 10^6$) — output the value of the $k$-load of the set. |
It is guaranteed that the sum of $n$ across all test cases does not exceed $2 \cdot 10^5$, and the same holds for $m$. |
For each test case, output the answers to the operations of type "?". |
There is an integer sequence $a$ of length $n$, where each element is initially $-1$. |
Misuki has two typewriters where the first one writes letters from left to right, with a pointer initially pointing to $1$, and another writes letters from right to left with a pointer initially pointing to $n$. |
Misuki would choose one of the typewriters and use it to perform the following operations until $a$ becomes a permutation of $[1, 2, \ldots, n]$ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.