• + 5 comments

    In this above solution the run time is O(3n) and we could make this as O(n) by using the dict to track the count of integers like positive, negative and zero values.

    size_of_list = int(input())
    list_of_int = map(int, raw_input().split(" "))
    
    count_of_deci = {"posi" : 0,
                  "neg" : 0,
                  "zero" : 0}
    for ele in list_of_int:
        if ele < 0:
            count_of_deci["neg"] += 1
        elif ele == 0:
            count_of_deci["zero"] += 1
        elif ele > 0:
            count_of_deci["posi"] += 1
    
    print "%.3f" % float(float(count_of_deci["posi"])/size_of_list)
    print "%.3f" % float(float(count_of_deci["neg"])/size_of_list)
    print "%.3f" % float(float(count_of_deci["zero"])/size_of_list)