3/9/25, 10:21 PM Problem - B - Codeforces
Enter | Register
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
Codeforces Blitz Cup 2025 Final Rounds Have Started! Join the stream now: https://youtu.be/rbHFLNg7Nkc. ×
PROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS HACKS ROOM STANDINGS CUSTOM INVOCATION
Ethflow Round 1 (Codeforces
B. Clockwork Round 1001, Div. 1 + Div. 2)
time limit per test: 1.5 seconds Finished
memory limit per test: 512 megabytes
→ Practice?
You have a sequence of n time clocks arranged in a line, where the initial time on the i -th clock is ai . In
each second, the following happens in order: Want to solve the contest problems after the
official contest ends? Just register for
practice and you will be able to submit
Each clock's time decreases by 1. If any clock's time reaches 0, you lose immediately. solutions.
You can choose to move to an adjacent clock or stay at the clock you are currently on.
Register for practice
You can reset the time of the clock you are on back to its initial value ai .
Note that the above events happen in order. If the time of a clock reaches 0 in a certain second, even if
you can move to this clock and reset its time during that second, you will still lose. → Virtual participation
You can start from any clock. Determine if it is possible to continue this process indefinitely without Virtual contest is a way to take part in past
contest, as close as possible to participation
losing. on time. It is supported only ICPC mode for
virtual contests. If you've seen these
problems, a virtual contest is not for you -
Input solve these problems in the archive. If you
The first line of input contains a single integer t (1 ≤ t ≤ 10
4
) — the number of test cases. just want to solve some problem from a
contest, a virtual contest is not for you -
solve this problem in the archive. Never use
For each test case, the first line contains a single integer n (2
5
≤ n ≤ 5 ⋅ 10 ) — the number of time someone else's code, read the tutorials or
communicate with other person during a
clocks. virtual contest.
9
The second line contains n integers a1 , a2 , … , an (1 ≤ ai ≤ 10 ) — the initial times set on the Start virtual contest
clocks.
https://codeforces.com/contest/2062/problem/B 1/3
3/9/25, 10:21 PM Problem - B - Codeforces
5
It is guaranteed that the sum of n over all test cases does not exceed 5 ⋅ 10 . → Problem tags
Output
For each test case, print "YES" (without quotes) if it is possible to continue this process indefinitely, or greedy math *900
"NO" (without quotes) otherwise. No tag edit access
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be
→ Contest materials
recognized as a positive response).
Example Announcement (en)
input Copy Tutorial (en)
5
2
4 10
2
2 2
3
4 10 5
3
5 3 5
5
12 13 25 17 30
output Copy
YES
NO
NO
YES
YES
Note
In the first test case, you can move back and forth between the two clocks, resetting them repeatedly.
In the third test case, assuming that you start from clock 1 and follow the strategy below:
Initially, a = [4, 10, 5] .
1. a becomes [3, 9, 4]. You move to clock 2 and reset its time, resulting in a = [3, 10, 4].
2. a becomes [2, 9, 3]. You move to clock 3 and reset its time, resulting in a = [2, 9, 5] .
3. a becomes [1, 8, 4]. You move to clock 2 and reset its time, resulting in a = [1, 10, 4].
4. a becomes [0, 9, 3]. You move to clock 1, but you lose because a1 reaches 0.
It can be proven that no other strategy allows you to continue this process indefinitely.
https://codeforces.com/contest/2062/problem/B 2/3
3/9/25, 10:21 PM Problem - B - Codeforces
Codeforces (c) Copyright 2010-2025 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: Mar/09/2025 22:21:33UTC+7 (l2).
Desktop version, switch to mobile version.
Privacy Policy
Supported by
https://codeforces.com/contest/2062/problem/B 3/3