118692024-11-12 23:19:07turierikHőségriadó (50 pont)python3Accepted 50/50127ms12132 KiB
n, k, l, f = map(int, input().split())
a = list(map(int, input().split()))

overf = []
underf = []
for t in a:
    overf.append(t > f)
    underf.append(t < f)

overfcon = []
underfcon = []
for i in range(n):
    if overf[i] == False:
        overfcon.append(0)
    else:
        overfcon.append(overfcon[i-1] + 1 if i > 0 else 1)
    if underf[i] == False:
        underfcon.append(0)
    else:
        underfcon.append(underfcon[i-1] + 1 if i > 0 else 1)

isalert = False
alertcount = 0

for i in range(n):
    if not isalert and overfcon[i] >= k:
        isalert = True
        alertcount += 1
    if isalert and underfcon[i] >= l:
        isalert = False

print(alertcount)
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/017ms3124 KiB
2Accepted0/0127ms11492 KiB
3Accepted2/216ms3128 KiB
4Accepted2/216ms3132 KiB
5Accepted2/216ms2992 KiB
6Accepted2/214ms3012 KiB
7Accepted2/216ms3012 KiB
8Accepted4/417ms3528 KiB
9Accepted4/457ms7940 KiB
10Accepted4/471ms9356 KiB
11Accepted4/475ms9864 KiB
12Accepted4/468ms9240 KiB
13Accepted4/4101ms12132 KiB
14Accepted4/424ms4104 KiB
15Accepted4/4119ms11300 KiB
16Accepted4/4108ms11480 KiB
17Accepted4/4108ms11968 KiB