Sort by

recency

|

3 Discussions

|

  • [deleted]
    + 0 comments

    I have a solution for this problem. Check my code when solved.

  • + 0 comments

    i also think testcases are wrong

  • + 2 comments

    i m unable to spot the error in this code so plz help.........my code is-----#include

    int main() {
        int i,t,n;
        long int a[1000],b[1000],m_sum1=0,m_sum2=0;
        long long int sum=0;
        scanf("%d",&t);
        while(t--)
            {
            scanf("%d",&n);
            for(i=0;i<n;i++)
                scanf("%ld",&a[i]);
            for(i=0;i<n;i++)
                scanf("%ld",&b[i]);
           for(i=0;i<n;i++)
               {
               if(a[i]>0) m_sum2 +=a[i];
               else    m_sum1+=a[i];
           }
               if(m_sum2>(-1*m_sum1)) sum=m_sum2*m_sum2;
               else
                   sum=m_sum1*m_sum1;
           m_sum1=0;m_sum2=0;
    
            for(i=0;i<n;i++)
            {
                 if(b[i]>0) m_sum2 +=b[i];
               else  m_sum1+=b[i];
            }
               if(m_sum2>(-1*m_sum1)) sum+=m_sum2*m_sum2;
               else
                   sum+=m_sum1*m_sum1;
    
    
    printf("%lld",sum);
    
        }
    
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */    
        return 0;
    }
    

No more comments