fork(2) download
  1. #include<stdio.h>
  2. int main(){
  3. long arr[10000];
  4. int t,n,p=0;
  5. scanf("%d",t);
  6.  
  7. while(t--)
  8. {
  9. long hap1=0,hap2=0;
  10. scanf("%d\n",n);
  11. for(int i=0;i<n;i++)
  12. {
  13. scanf("%d",arr[i]);
  14. }
  15.  
  16. for(int i=0;i<n;i++)
  17. {
  18. if(arr[i]>=0)
  19. {
  20. hap1+=arr[i];
  21. p++;
  22. }
  23. else
  24. {
  25. hap2+=arr[i];
  26. }
  27. }
  28. printf("%d\n",hap1*p+hap2);
  29. }
  30. return 0;}
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty