-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_20546.py
More file actions
54 lines (44 loc) · 1.15 KB
/
Copy pathbj_20546.py
File metadata and controls
54 lines (44 loc) · 1.15 KB
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
import sys
input = sys.stdin.readline
money = int(input().strip())
prices = list(map(int, input().split()))
# BNP (준현)
bnp_cash = money
bnp_stock = 0
# TIMING (성민)
timing_cash = money
timing_stock = 0
up = 0 # 연속 상승
down = 0 # 연속 하락
for i in range(len(prices)):
price = prices[i]
# ----- BNP -----
buy = bnp_cash // price
bnp_stock += buy
bnp_cash -= buy * price
# ----- TIMING -----
if i > 0:
if prices[i] > prices[i - 1]:
up += 1
down = 0
elif prices[i] < prices[i - 1]:
down += 1
up = 0
else:
up = down = 0
if down >= 3: # 3일 연속 하락 → 매수
buy = timing_cash // price
timing_stock += buy
timing_cash -= buy * price
elif up >= 3: # 3일 연속 상승 → 매도
timing_cash += timing_stock * price
timing_stock = 0
# 최종 자산
bnp_total = bnp_cash + bnp_stock * prices[-1]
timing_total = timing_cash + timing_stock * prices[-1]
if bnp_total > timing_total:
print("BNP")
elif bnp_total < timing_total:
print("TIMING")
else:
print("SAMESAME")