BOJ - 2491 - 수열
Updated:
import sys
def solution():
N = int(input())
arr = list(map(int, sys.stdin.readline().split()))
minDp = [0] * N
maxDp = [0] * N
maxDp[0] = 1
minDp[0] = 1
for i in range(1, N):
if arr[i] >= arr[i-1]: maxDp[i] = maxDp[i-1] + 1
else: maxDp[i] = 1
if arr[i] <= arr[i-1]: minDp[i] = minDp[i-1] + 1
else: minDp[i] = 1
print(max(max(maxDp), max(minDp)))
solution()
https://www.acmicpc.net/problem/2491
Leave a comment