Calculate the average
Xem dạng PDF        
            Gửi bài giải
        
    
        
        
    
    
    
    
    
        
        
                
        
            
        
        Điểm:
        
                1,00 (OI)        
    
    
        Giới hạn thời gian:
        1.0s
    
    
        Giới hạn bộ nhớ:
        256M
    
    
            Input:
            stdin
        
        
            Output:
            stdout
        
    
            Nguồn bài:
            
        
        
                    Dạng bài                
                
        
                Ngôn ngữ cho phép
            
            
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch            
        Enter a sequence of ~N~ integers ~A_1, A_2, \ldots, A_N~.
Print the average of the negative elements to the screen.
Input
- The first line contains an integer ~N~.
 - The next line contains ~N~ integer numbers ~A_1, A_2, \ldots, A_N~.
 
Output
- Print the average of the negative elements, rounded to two decimal places. If there are no negative numbers in the sequence, print ~-1~.
 
Sample Input
5
-1 2 -3 4 -5 
Sample Output
-3.00
Constraints
- ~1 \leq N \leq 10^5~.
 - ~|A_i| \leq 10^9~.
 
Bình luận