Colleen is turning  years old! Therefore, she has  candles of various heights on her cake, and candle  has height . Because the taller candles tower over the shorter ones, Colleen can only blow out the tallest candles.

Given the  for each individual candle, find and print the number of candles she can successfully blow out.

Input Format

The first line contains a single integer, , denoting the number of candles on the cake. 
The second line contains  space-separated integers, where each integer  describes the height of candle .

Constraints

Output Format

Print the number of candles Colleen blows out on a new line.

Sample Input 0

4
3 2 1 3

Sample Output 0

2

Explanation 0

We have one candle of height , one candle of height , and two candles of height . Colleen only blows out the tallest candles, meaning the candles where . Because there are  such candles, we print  on a new line.

 

 

 


두번 for문 쓰지 않고


한번에 비교하면서 카운트 하기 


(max 변화시 sum 다시 1로 초기화)



  public static void main(String[] args) {

  

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        

        int max = 0;

        int sum = 0;

        int num;

        

        for(int i =0; i < n; i++){

            num = in.nextInt();

            

            if(num > max){

                sum = 1;

                max = num;

            }else if(num == max){

                sum++;

            }

        }

        System.out.println(sum);

    }


+ Recent posts