-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11055.cpp
More file actions
37 lines (28 loc) · 763 Bytes
/
11055.cpp
File metadata and controls
37 lines (28 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include <string>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int N; int arr[1001]; cin >> N;
int dp[1001];
int max = 0;
for (int i = 0; i < N; i++) {
cin >> arr[i];
dp[i] = arr[i];
if (max < arr[i])max = arr[i];
}
for (int i = 0; i < N; i++) {
for (int prev = 0; prev < i; prev++) {
if (arr[i] > arr[prev]) {
if (dp[i] < dp[prev] + arr[i]) {
dp[i] = dp[prev] + arr[i];
if (max < dp[i])max = dp[i];
}
}
}
}
cout << max;
}