QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#7728. 拉面

统计

Grammy 喜欢吃面条。她将一根很长的面条分成了 $N$ 段,每段长度为单位长度。第 $i$ 段面条的美味程度为 $a_i$。她想在吃之前通过重复若干次(可能为零次)以下操作,将面条折叠成单位长度的一块。

设当前面条的长度为 $n$。在每次操作中,Grammy 可以选择一个长度 $\ell$,满足 $2\ell \le n$ 且对于所有 $i \le \ell$ 都有 $a_i > 0$,并将面条 $a_1, a_2, \dots, a_\ell, a_{\ell+1}, \dots, a_{2\ell}, a_{2\ell+1}, \dots, a_n$ 折叠为 $a_{\ell+1} + a_\ell, a_{\ell+2} + a_{\ell-1}, \dots, a_{2\ell} + a_1, a_{2\ell+1}, \dots, a_n$,其中 $n$ 是操作前面条的长度。操作后,面条的长度变为 $n - \ell$。

Grammy 想知道她是否能将面条折叠成长度为 1,你能告诉她吗?

输入格式

第一行包含一个整数 $N$ ($1 \le N \le 100\,000$)。

第二行包含 $N$ 个整数 $a_i$ ($-20\,000 \le a_i \le 20\,000$),表示面条每一部分的美味程度。

输出格式

如果 Grammy 可以将面条折叠成长度为 1,输出一行单词 “Yes”。否则,输出一行单词 “No”。

样例

输入 1

3
1 2 -5

输出 1

Yes

输入 2

5
2 -5 2 3 1

输出 2

No

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.