// ID:1285 TITLE:最大上升子序列和 #include const int MAX = 1001; int main() { int n, a[1001], b[1001], total = -1; std::cin >> n; for (int i = 1; i <= n; i++) { std::cin >> a[i]; b[i] = a[i]; } for (int i = 0; i <= n; i++) { for (int j = 0; j < i; j++) { if (a[i] > a[j]) { if (a[i] > a[j]) { b[i] = std::max(b[i], b[j] + a[i]); } } } } for (int i = 1; i <= n; i++) { total = std::max(total, b[i]); } std::cout << total; }