using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; namespace Csharp { class Program { static int[] Arr = new int[1001]; static int[] Memo = new int[1001]; static int N, Ans; static void Main(string[] args) { N = Convert.ToInt32(Console.ReadLine()); var inputs = Console.ReadLine().Split(); for (int i = 0; i < N; ++i) { Memo[i] = Arr[i] = Convert.ToInt32(inputs[i]); for (int j = 0; j < i; ++j) { if (Arr[j] < Arr[i] && Memo[i] < Memo[j] + Arr[i]) Memo[i] = Memo[j] + Arr[i]; } Ans = Math.Max(Ans, Memo[i]); } Console.Write(Ans); } } } |