getting wrong answer for test case 1 and runtime error for testcase 2
Wrong answer for two test cases
#include<bits/stdc++.h> using namespace std; typedef long long int lli; lli solve(lli* arr,lli n) { lli dp[n][2]; for(lli i=0;i<n;i++) { for(lli j=0;j<2;j++) { dp[i][j] = 0; } } if(arr[0]>0) { dp[0][0] = arr[0]; dp[0][1] = 0; } else if(arr[0]<0) { dp[1][0] = 0; dp[1][1] = arr[0]; } for(lli i=1;i<=n;i++) { if(arr[i]>0) { dp[i][0] = max(arr[i],arr[i]*dp[i-1][0]); dp[i][1] = arr[i]*dp[i-1][1]; } else if(arr[i]<0) { dp[i][0] = arr[i]*dp[i-1][1]; dp[i][1] = min(arr[i],arr[i]dp[i-1][0]); } } lli ans = INT_MIN; for(lli i=0;i<n;i++) { ans = max(ans,dp[i][0]); } return ans; } int main() { lli n; cin>>n; lli arr = new lli[n]; for(lli i=0;i<n;i++) { cin>>arr[i]; } cout<<solve(arr,n)<<endl; }
go to this link ->https://ide.codingblocks.com/
paste ur code in the ediotor
then press ctrl +s and save
a link will be generated in ur search bar, share that link with me
sir still getting wrong answer for test case 1
refreshed , still it showing the same
@dashankbhoir60
try submitting it here->
https://hack.codingblocks.com/app/contests/1338/375/problem
sir still it is the same
copy my shared code again , and then try to submit.
also share screenshot that u r getting
also share the code that u r submitting
no sir , it is not working
ty sir got AC now, it is working