Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int value[1001];
- int DP[1001];
- int main()
- {
- int max = 0, N;
- scanf("%d", &N);
- for (int a = 1; a <= N; a++) {
- scanf("%d", &value[a]);
- DP[a] = value[a];
- }
- for (int a = 2; a <= N; a++) {
- for (int b = 1; b <= a; b++) {
- max = DP[b] + value[a - b];
- if (max > DP[a])
- DP[a] = max;
- }
- }
- printf("%d\n", DP[N]);
- return 0;
- }
Add Comment
Please, Sign In to add comment