본문 바로가기
python-algorithm

[백준] 1668

by 무적김두칠 2021. 1. 6.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import sys
n=int(sys.stdin.readline())
tmp=[]
for _ in range(n):
    tmp.append(int(sys.stdin.readline()))
leftmax=tmp[0]
rightmax=tmp[len(tmp)-1]
cntLeft=1
cntRight=1
for i in range(n):
    if tmp[i]>leftmax : leftmax=tmp[i]; cntLeft+=1
for i in range(n):
    if tmp[n-1-i]>rightmax : rightmax=tmp[n-1-i]; cntRight+=1
print(cntLeft)
print(cntRight)
cs

문제 에서 말한 왼쪽에서 보는 경우와 오른쪽에서 보이는 경우를 천천히 구현하시면 쉽습니다.

반응형

'python-algorithm' 카테고리의 다른 글

[백준] 1731  (0) 2021.01.06
[백준] 1681  (0) 2021.01.06
[백준] 1568  (0) 2021.01.06
[백준] 1551  (0) 2021.01.06
[백준] 1434  (0) 2021.01.06

댓글