Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 662 |

@arpitsatnalika | 629 |

@code_it_ | 591 |

@prakharxyz | 583 |

@tujhekya | 542 |

@Rahul Jadhav 1 | 458 |

@sivanandh03 | 448 |

@satyam0460 | 433 |

@iamronak | 424 |

@imnm | 424 |

@18eumc107 | 421 |

Complete Leaderboard |

A Fox is looking to collect some coins placed in a line. The fox is very greedy and follows an unusual way of collecting coins. The Fox has decided that it will collect coins in an increasing order only since she always craves for more money and all the coins must be contiguous. It wants to maximize the amount of money it collects. Each coin has its value printed on it.

Unfortunately, the Fox is greedy but not intelligent enough to find the solution and asks you for help. Print the maximum amount of money it will take home. You are given the value of each coin in an array in the order in which the coins are placed.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Each test case contains the number of elements in the array a[] as n and next line contains space separated n elements in the array.

**Output:**

Print an integer which is the required answer.

**Constraints:**

1<=T<=100

1<=n<=1000

1<=a[i]<=100000

**Example:
Input:**

2

6

2 1 4 7 3 6

5

38 7 8 10 12

**Output:**

12

38

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Greedy Fox

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.