QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100

#4837. 拉面

Estadísticas

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.