#include
using namespace std;
long long int minSum(int *nums,int n)
{
long long int dp[n];
if(n < 3)
return 0;
dp[0] = nums[0];
dp[1] = nums[1];
dp[2] = nums[2];
for(int i = 3;i < n;++i)
dp[i] = nums[i] + min(min(dp[i-1],dp[i-2]),dp[i-3]);
return min(min(dp[n-3],dp[n-2]),dp[n-1]);
}
int main () {
int n;
cin >> n;
int nums[n];
for(int i = 0;i < n;++i)
cin >> nums[i];
cout << minSum(nums,n) << endl;
return 0;
}
Why my code is not working for one test case
Hi
yes you are absolutely right. There is an issue with the test case.
Our tech team is working towards it, we will remove that bug soon.
Thank you for your participation.