Hackerrank | Birthday Cake Candles


link


https://www.hackerrank.com/challenges/birthday-cake-candles/problem

problem



最大値に応じて同じ数字を出力
受信数>最大数の検索>最大数に等しいかどうか>出力

code

#define _CRT_SECURE_NO_WARNINGS
#incldue <stdio.h>

int main() 
{	
    int n;
    int max;
    int res = 0;
    
    scanf("%d", &n);
    
    int ar[10000000] = {0,};
    
    for (int i=0; i<n; i++)
    	scanf("%d", &ar[i]);
    
    max = ar[0];
    
    for (int i=1; i<n; i++)
    	if (ar[i] > max)
        	max = ar[i];
    
    for (int i=0; i<n; i++)
    	if (ar[i] == max)
        	res++;
    
    printf("%d", res);
    
    return 0;

result