the sample test case is passing but it is showing run error when I am submitting it.
SUPW -arranging work for nikhil so that he gets minimum work hours
You should return min(dp[n-1],min(dp[n-2],dp[n-3]))
yes i am already doing that
here is my code please suggest changes
#include
#include
using namespace std;
long int minutes(long int *a,int n)
{
long int dp[n];
dp[0]=a[0];
dp[1]=a[1];
dp[2]=a[2];
for(long int i=3;i<n;i++)
{
dp[i]=min(dp[i-1],min(dp[i-2],dp[i-3]))+a[i];
}
long int result=min(dp[n-1],min(dp[n-2],dp[n-3]));
return result;
}
int main () {
long int n;
cin>>n;
long int a[n];
for(long int i=0;i<n;i++)
cin>>a[i];
cout<<minutes(a,n)<<endl;
return 0;
}
What issue u are facing now?