Quick actions

cmd+k|ctrl+k

Navigation

Languages

18. 층간소음

Snippet info

Language

C

Visibility

public

Author

kim112mgxld

Created

2020-09-23T07:28:01Z

Updated

2020-09-23T08:27:15Z

#include <stdio.h>
#include <stdlib.h>
#define MAX 101

int main(void) {
    int N = 0, M = 0, max = 0, check[MAX];
    
    scanf("%d %d", &N, &M);
    
    for (int i = 0; i < N; i++) {
        scanf("%d", &check[i]);
    }
    
    for (int i = 0; i < N; i++) {
        if (check[i] >= M) {
            int res = 0;
            
            for (int j = i; j < N; j++) {
                if (check[j] >= M) {
                    res++;
                } else {
                    if (res > max) {
                        max = res;
                    }
                    
                    break;
                }
            }
        }
    }
    
    printf("%d", (max == 0) ? -1 : max);
    
    return 0;
}
INFO