1seul357
[SWEA] gravity 본문
test_case = int(input())
for tc in range(test_case):
N = int(input())
Height = list(map(int, input().split())) //가로 길이 입력받기
max_num = 0
for j in range(N): //기준이 되는 j
cnt = 0
for i in range(j+1, N): //인덱스 i
if Height[j] > Height[i]: //값이 더 크다면
cnt += 1 //이동시킬 수 있다.
if cnt > max_num: //낙차가 가장 큰 값 찾기
max_num = cnt
print('#{} {}' .format(tc+1, max_num))
'알고리즘 > SWEA' 카테고리의 다른 글
[SWEA] 모음이 보이지 않는 사람 (0) | 2021.12.04 |
---|---|
[SWEA] 문자열의 거울상 (0) | 2021.12.03 |
[SWEA] min max (0) | 2021.12.03 |
[SWEA] 숫자 카드 (0) | 2021.12.03 |
[SWEA] 구간 합 (0) | 2021.12.03 |