Download benchmarks/Algorithms/max_sum_increasing_sequence/solution.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 440 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/max_sum_increasing_sequence/solution.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/max_sum_increasing_sequence/solution.c
-
curl -L -o solution.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/max_sum_increasing_sequence/solution.c
440 Bytes
| int maxSumIncreasingSequence(int *nums, int numsSize) | |
| { | |
| int dp[100000]; | |
| dp[0] = nums[0]; | |
| int ans = nums[0]; | |
| for (int i = 1; i < numsSize; ++i) { | |
| dp[i] = nums[i]; | |
| for (int j = 0; j < i; ++j) { | |
| if (nums[j] < nums[i]) { | |
| int candidate = dp[j] + nums[i]; | |
| if (candidate > dp[i]) { | |
| dp[i] = candidate; | |
| } | |
| } | |
| } | |
| if (dp[i] > ans) { | |
| ans = dp[i]; | |
| } | |
| } | |
| return ans; | |
| } | |