CF2135D1 From the Unknown (Easy Version)
Description
This is the easy version of the problem. The difference between the versions is that in this version, there are no constraints on the sum of the lengths of the articles over all queries. You can hack only if you solved all versions of this problem.
This is an interactive problem.
The RiOI Team has recently developed a text editor named RiOI Editor. The editor works with exactly one integer parameter $$$W$$$ — the width of each line. It is known that $$$1 \\leq W \\leq 10^5$$$.
As you cannot understand the RiOI Language, from your point of view, words differ from each other only by their length. Hence, an article of length $$$n$$$ is defined as a sequence $$$a$$$ consisting of $$$n$$$ positive integers, where $$$a\_i$$$ is the length of the $$$i$$$-th word in the article. The RiOI Editor displays the article $$$\[a\_1, a\_2,\\ldots, a\_n\]$$$ on screen as follows:
- If $$$\\max(a\_1, a\_2, \\ldots, a\_n) > W$$$, the editor is unable to display the article;
- Otherwise, the editor is able to display the article by the following process:
- Initially, $$$l = 1$$$, and $$$s = 0$$$. During the whole process, $$$l$$$ always denotes the current number of lines in the editor, and $$$s$$$ always denotes the sum of lengths of words in the last line;
- Then, for each $$$1\\le i\\le n$$$:
- If $$$s + a\_i \\leq W$$$, the word is inserted at the end of the current line. Thus, $$$l$$$ remains unchanged, and $$$s$$$ gets increased by $$$a\_i$$$.
- Otherwise, the word is inserted into a new line. Thus, $$$l$$$ becomes $$$l + 1$$$, and $$$s$$$ becomes $$$a\_i$$$.
- The number of lines needed to display the article is the final value of $$$l$$$.
You are very interested in the editor, so you decide to find out the value of $$$W$$$ by inputting some articles into the editor and observing the number of lines needed to display each article.
Formally, you can query the jury at most $$$2$$$ times. In each query, you input an article $$$\[a\_1, a\_2, \\ldots, a\_n\]$$$ ($$$1\\leq n \\leq 10^5$$$) to the editor, and the jury will respond to you with:
- The number of lines needed to display the article, if the editor is able to display it;
- $$$0$$$, if the editor is unable to display the article.
Input Format
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10$$$). The description of the test cases follows.
Output Format
N/A
Explanation/Hint
In the first test case:
- For the first query, the total length of the words is $$$1+9+4+6+1=21$$$, and the article is displayed in two lines, so $$$W<21$$$;
- For the second query, the total length of the words is $$$10+10=20$$$, and the article is displayed in one line, so $$$W\\ge 20$$$.
Thus, we have determined $$$W = 20$$$.
In the second test case, the editor cannot display the article in the only query. Thus, $$$W < 2$$$, so it can only be $$$1$$$.