[SWEA]1736普通数字


Python Code

T = int(input())
for tc in range(1, T+1):
    N = int(input())
    numbers = list(map(int, input().split()))
    cnt = 0
    for i in range(N-2):
        if numbers[i] < numbers[i+1] < numbers[i+2]:
            cnt += 1
        elif numbers[i+2] < numbers[i+1] < numbers[i]:
            cnt += 1
    print('#{} {}'.format(tc, cnt))