Anshul, Usama And Punishment - B

2.8

22 votes
Easy
Problem

Anshul and Usama are fond of games and devote most of their time playing them. On one hand Anshul likes to play outdoor games like football, cricket, etc whereas on the other hand Usama likes to play mobile games like Clash of Clans, Mini Militia, etc. One day their teacher decided to punish them. As punishment, their teacher sent them to a building and locked all the exit points of that building. After locking the exit points, their teacher informed them from outside that the only way to come out of the building was by solving a problem.

The problem he gave was that they will be given some initial terms of a series and they have to use the series and tell him the maximum value of (|Ai + Aj|+|Ai - Aj|) where Ai and Aj are some ith and jth term of the series with the condition 0 <= i,j < n. Also, 'i' can not be equal to 'j'.

The initial terms of the series are 20, 30, 40, 90, 80, 270,...

INPUT
The value of n= 62

OUTPUT
Output the maximum value of (|Ai + Aj|+|Ai - Aj|).

  • To see how to submit solution please check this link

Compile and Test can give Wrong Answer. Once you have written your answer, press Submit button to check your result.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?