Question: PointsCollection 1 Problem Statement You are designing a game where the player collects points by visiting a series of levels arranged in a linear sequence.

PointsCollection
1 Problem Statement
You are designing a game where the player collects points by visiting a series of levels arranged in a linear sequence.
Each level i has a certain number of points points[i] that the player can collect.
However, to make the game challenging, the player cannot visit two consecutive levels.
Your task is to determine the maximum points the player can collect if they start at any level and follow the rule of not visiting two consecutive levels.
Input Format
The first line contains an integer N representing the number of levels.
The next line contains an array points of length N where points[i] represents the points available at level i, these elements are separated by space
Output Format
Print an integer representing the maximum points the player can collect.
Conetrninto
0s=poin'shx=108
Sample Testcase 1
Testcase Input
4
1051520
Testcase Output
30
xplanation
tart at level 0(10 points), skip level 1, and go to level 2(15 poi
otal =10+15=25.
tart at level 0(10 points), skip levels 1 and 2, and go to level 3
oints). Total =10+20=30.
tart at level 1(5 points), skip level 2, and go to level 3(20 poil
otal =5+20=25.
tart at level 2(15 points), skip level 3. Total =15.
art at level 3(20 points). Total =20.
le maximum points that can be collected in this case is 30.
points). Total =10+20=30.
Start at level 1(5 points), skip level 2, and go to level 3(20 points).
Total =5+20=25.
Start at level 2(15 points), skip level 3. Total =15.
Start at level 3(20 points). Total =20.
The maximum points that can be collected in this case is 30.
Sample Testcase 2
Testcase Input
6
129450
Testcase Output
15
Explanation
Start at level 0(1 point), skip level 1, go to level 2(9 points), and
hen skip level 3 to go to level 4(5 points). Total =1+9+5=15.
tart at level 1(2 points), skip level 2, go to level 3(4 points), and
hen skin level 1 to an to level 5(A nointel Total -2+1=6
Sample Testcase 2
Testcase Input
123450
Testcase Output
15
Explanation
Start at level 0(1 point), skip level 1, go to level 2(9 points), and
then skip level 3 to go to level 4(5 points). Total =1+9+5=15.
Start at level 1(2 points), skip level 2, go to level 3(4 points), and
then skip level 4 to go to level 5(0 points). Total =2+4=6.
Start at level 2(9 points), skip level 3, and go to level 4(5 points).
Total =9+5=14.
Start at level 3(4 points), skip level 4, and go to level 5(0 points).
Total =4.
Start at level 4(5 points). Total =5.
Start at level 5(0 points). Total =0.
The maximum points that can be collected in this case is 15. in C++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!