Codeforces Round 645 (Div. 2)
E
Are You Fired?
Codeforces
2400
原题
← DF →
翻译中…

Levian works as an accountant in a large company. Levian knows how much the company has earned in each of the $n$ consecutive months — in the $i$-th month the company had income equal to $a_i$ (positive income means profit, negative income means loss, zero income means no change). Because of the general self-isolation, the first $\lceil \tfrac{n}{2} \rceil$ months income might have been completely unstable, but then everything stabilized and for the last $\lfloor \tfrac{n}{2} \rfloor$ months the income was the same.

翻译中…

Levian decided to tell the directors $n-k+1$ numbers — the total income of the company for each $k$ consecutive months. In other words, for each $i$ between $1$ and $n-k+1$ he will say the value $a_i + a_{i+1} + \ldots + a_{i + k - 1}$. For example, if $a=[-1, 0, 1, 2, 2]$ and $k=3$ he will say the numbers $0, 3, 5$.

翻译中…

Unfortunately, if at least one total income reported by Levian is not a profit (income $\le 0$), the directors will get angry and fire the failed accountant.

翻译中…

Save Levian's career: find any such $k$, that for each $k$ months in a row the company had made a profit, or report that it is impossible.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($2 \le n \le 5\cdot 10^5$) — the number of months for which Levian must account.

翻译中…

The second line contains $\lceil{\frac{n}{2}}\rceil$ integers $a_1, a_2, \ldots, a_{\lceil{\frac{n}{2}}\rceil}$, where $a_i$ ($-10^9 \le a_i \le 10^9$) — the income of the company in the $i$-th month.

翻译中…

Third line contains a single integer $x$ ($-10^9 \le x \le 10^9$) — income in every month from $\lceil{\frac{n}{2}}\rceil + 1$ to $n$.

翻译中…

Output

翻译中…

In a single line, print the appropriate integer $k$ or $-1$, if it does not exist.

翻译中…

If there are multiple possible answers, you can print any.

翻译中…

Note

翻译中…

In the first example, $k=2$ and $k=3$ satisfy: in the first case, Levian will report the numbers $1, 1$, and in the second case — one number $3$.

翻译中…

In the second example, there is no such $k$.

翻译中…

In the third example, the only answer is $k=4$: he will report the numbers $1,2,3$.

翻译中…

样例

Input #1
3
2 -1
2
Output #1
2
InputCopy OutputCopy
Input #2
5
2 2 -8
2
Output #2
-1
InputCopy OutputCopy
Input #3
6
-2 -2 6
-1
Output #3
4
InputCopy OutputCopy
题目信息
题号
1358E
时间限制
2 s
内存限制
256 MB
标签
构造
数据结构
贪心
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。