|
nivashkr | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
Temporarily, Codeforces is operating in a limited mode due to technical reasons (historical data is unavailable). This will be fixed in the next ×
few hours.
PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST
Codeforces Round 693 (Div. 3)
C. Long Jumps Finished
time limit per test: 2 seconds
Practice
memory limit per test: 256 megabytes
Polycarp found under the Christmas tree an array a of n elements and instructions for playing
with it:
→ Virtual participation
At first, choose index i (1 ≤ i ≤ n ) — starting position in the array. Put the chip at the index
Virtual contest is a way to take part in past
i (on the value ai ).
contest, as close as possible to participation
While i ≤ n, add ai to your score and move the chip ai positions to the right (i.e. replace i on time. It is supported only ICPC mode for
virtual contests. If you've seen these
with i + ai ). problems, a virtual contest is not for you -
If i > n, then Polycarp ends the game. solve these problems in the archive. If you
just want to solve some problem from a
contest, a virtual contest is not for you -
For example, if n = 5 and a = [7, 3, 1, 2, 3] , then the following game options are possible: solve this problem in the archive. Never use
someone else's code, read the tutorials or
+7
communicate with other person during a
Polycarp chooses i = 1 . Game process: i = 1 ⟶ 8 . The score of the game is: a1 = 7 . virtual contest.
+3 +3
Polycarp chooses i = 2 . Game process: i = 2 ⟶ 5 ⟶ 8 . The score of the game is: Start virtual contest
a2 + a5 = 6 .
+1 +2
Polycarp chooses i = 3 . Game process: i = 3 ⟶ 4 ⟶ 6 . The score of the game is:
→ Clone Contest to Mashup
a3 + a4 = 3 .
+2
You can clone this contest to a mashup.
Polycarp chooses i = 4 . Game process: i = 4 ⟶ 6 . The score of the game is: a4 = 2 .
+3
Clone Contest
Polycarp chooses i = 5 . Game process: i = 5 ⟶ 8 . The score of the game is: a5 = 3 .
Help Polycarp to find out the maximum score he can get if he chooses the starting index in an
optimal way. → Submit?
Input Language: GNU G++17 7.3.0
The first line contains one integer t (1
4
≤ t ≤ 10 ) — the number of test cases. Then t test
cases follow. Choose
Choose File No file chosen
file:
The first line of each test case contains one integer n (1
5
≤ n ≤ 2 ⋅ 10 ) — the length of the Submit
array a.
9
The next line contains n integers a1 , a2 , … , an (1 ≤ ai ≤ 10 ) — elements of the array a.
→ Problem tags
5
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10 .
dp graphs *1100
No tag edit access
Output
For each test case, output on a separate line one number — the maximum score that Polycarp
can get by playing the game on the corresponding array according to the instruction from the → Contest materials
statement. Note that Polycarp chooses any starting position from 1 to n in such a way as to
maximize his result. Announcement
Example Tutorial
input Copy
4
5
7 3 1 2 3
3
2 1 4
6
2 1000 2 3 995 1
5
1 1 1 1 1
output Copy
7
6
1000
5
Note
The first test case is explained in the statement.
In the second test case, the maximum score can be achieved by choosing i = 1 .
In the third test case, the maximum score can be achieved by choosing i = 2 .
In the fourth test case, the maximum score can be achieved by choosing i = 1 .
Codeforces (c) Copyright 2010-2025 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: Aug/26/2025 05:20:23UTC+5.5 (k1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions
Supported by