-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathY_์์ด.py
78 lines (72 loc) ยท 1.59 KB
/
Y_์์ด.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'''
case 1
์ฆ๊ฐ๋ผ๋ฉด ๋ฌด์กฐ๊ฑด ์ฆ๊ฐ์์ด๋ฐ์ ์์
case 2
๊ฐ์๋ผ๋ฉด ๋ฌด์กฐ๊ฑด ๊ฐ์์์ด๋ฐ์ ์์
๋ฐ๊ฟ์ค์ผํ๋ค๋ฉด 0 index ๊ฐ์ด ์ต๋ ํน์ ์ต์๊ฐ์ด์ด์ผํจ.
์ญ ์ฒดํฌํ๋ค๊ฐ ์ฆ๊ฐํ๋ฉด ์ฆ๊ฐ์์ด ํ๋๊ทธ ๊ฐ์ํ๋ฉด ๊ฐ์์์ด ํ๋๊ทธ
'''
from collections import deque
n = int(input())
if n <= 2:
print(0)
num = list(map(int,input().split()))
q = deque(num)
v = q.popleft()
d = 0
count = 0
while q:
if count == 4:
break
now = q.popleft()
if d == 0:
if v < now:
d = 1
count +=1
elif v > now:
d = -1
count +=1
else:
d = 0
elif d == 1:
if now < v:
d = 0
count += 1
elif
# pCount = 0
# d = 0
# def getDir(idx):
# if num[idx] < num[idx+1]:
# return 1
# elif num[idx] > num[idx+1]:
# return -1
# else:
# if idx+2 < n:
# return getDir(idx+1)
# else:
# return d*(-1)
# d = getDir(0)
# index = 0
# for i in range(1,n-1):
# if d == 1:
# if num[i] > num[i+1]:
# if pCount == 1:
# pCount = 2
# break
# else:
# pCount = 1
# index = i
# d = getDir(i+1)
# else:
# if num[i] < num[i+1]:
# if pCount == 1:
# pCount = 2
# break
# else:
# pCount = 1
# index = i
# d = getDir(i+1)
# if pCount == 2:
# print(-1)
# else:
# print(index+1)