Favorite summation of the largest ascending subsequence

TimeLimit:1000MS  MemoryLimit:128MB
64-bit integer IO format:%lld
未提交 | 登录后收藏
Problem Description

Given a sequence of integers of length n, a1, a2... , an.

Now select a strictly ascending subsequence of this sequence, requiring that the sum of the elements of the selected subsequence be as large as possible.

What is the maximum value?

Input

The first line contains the integer n.

The second line contains n integers a1, a2... , an.

(1≤n≤105,1≤ai≤109

Output

Output the sum of the largest ascending subsequence.

SampleInput
4
1 9 7 10
SampleOutput
20

hint: For example, we pick 1,9,10.
Submit
题目统计信息详细
总AC数13
通过人数7
尝试人数8
总提交量31
AC率22.58%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
作者

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: