QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#1355. Trò chơi nhịp điệu

Statistics

Bạn được cho một dãy số nguyên $A = (A_1, A_2, \dots, A_N)$ có độ dài $N$.

Bạn có thể thực hiện thao tác sau đây bất kỳ số lần nào (có thể là không lần nào): * Chọn một chỉ số $i$ ($1 \le i \le N-1$) sao cho $A_i$ và $A_{i+1}$ đều là số dương. Sau đó, giảm cả $A_i$ và $A_{i+1}$ đi $1$.

Hãy xác định xem liệu có thể làm cho tất cả các phần tử của dãy $A$ bằng $0$ hay không.

Dữ liệu vào

Dòng đầu tiên chứa số nguyên $N$ ($2 \le N \le 2 \times 10^5$). Dòng thứ hai chứa $N$ số nguyên $A_1, A_2, \dots, A_N$ ($0 \le A_i \le 10^9$).

Dữ liệu ra

In ra Yes nếu có thể làm cho tất cả các phần tử bằng $0$, ngược lại in ra No.

Ví dụ

Dữ liệu vào 1

3
2 2 2

Dữ liệu ra 1

No

Ghi chú

Trong ví dụ 1, ta có thể thực hiện thao tác với $i=1$ hai lần để được $(0, 0, 2)$, sau đó không thể thực hiện thêm thao tác nào nữa. Tuy nhiên, nếu ta thực hiện thao tác với $i=2$ hai lần trước, ta được $(2, 0, 0)$, sau đó cũng không thể thực hiện thêm. Thực tế, với ví dụ 1, câu trả lời là No.

Dữ liệu vào 2

3
1 2 3

Dữ liệu ra 2

No

Dữ liệu vào 3

4
1 2 3 4

Dữ liệu ra 3

No

Dữ liệu vào 4

5
1 1 1 1 1

Dữ liệu ra 4

No

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#596Editorial Open集训队作业 解题报告 by 朱乐轩Qingyu2026-01-02 22:44:00 Download

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.