18. 층간소음

Run Settings
LanguageC
Language Version
Run Command
#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; }
Editor Settings
Theme
Key bindings
Full width
Lines