#include<stdio.h> int main() { int avi[50],b,c,i,j,count=0; scanf("%d",&c); for(i=0;i<c;i++) { scanf("%d",&b); for(j=0;j<b;j++) { scanf("%d",&avi[j]); } for(j=0;j<b;j++) { if(avi[j]>0) { count++;} } printf("%d\n",count); count=0; } return 0; }
Problem Description
Count the number of distinct absolute values from a sorted array containing N integers. An absolute value of a number is | a | ( positive ) value of it.Test Case 1
Input (stdin)
3 4 -35 73 73 73 9 -44 -31 -6 6 46 52 52 55 93 3 23 45 19
Expected Output
3 6 3
Test Case 2
Input (stdin)
1 4 -35 7 85 85
Expected Output
3
No comments:
Post a Comment