118682024-11-12 23:17:07turierikHőségriadó (50 pont)python3Wrong answer 22/50122ms12388 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] >= k:
        isalert = False

print(alertcount)
SubtaskSumTestVerdictTimeMemory
base22/50
1Accepted0/017ms3120 KiB
2Accepted0/0122ms12048 KiB
3Accepted2/216ms3252 KiB
4Accepted2/216ms3148 KiB
5Accepted2/217ms3340 KiB
6Accepted2/217ms3148 KiB
7Accepted2/217ms3128 KiB
8Accepted4/418ms3256 KiB
9Accepted4/457ms7936 KiB
10Wrong answer0/465ms9572 KiB
11Wrong answer0/479ms9880 KiB
12Wrong answer0/467ms9380 KiB
13Wrong answer0/497ms12388 KiB
14Wrong answer0/425ms4152 KiB
15Wrong answer0/4115ms11820 KiB
16Wrong answer0/4116ms11736 KiB
17Accepted4/4111ms12284 KiB