Skip to content

Commit c9d90ce

Browse files
committed
[BOJ] #20545.기적의 매매법 / 실버5 / 60(∆)
1 parent b808d6d commit c9d90ce

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

learntosurf/BruteForce/.DS_Store

6 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 2024-11-12-[BOJ]-#20545-기적의매매법","url":"/Users/learntosurf/Desktop/codingtest_algorithm_study/learntosurf/Simulation/2024-11-12-[BOJ]-#20545-기적의매매법.py","tests":[{"id":1731373332963,"input":"100\n10 20 23 34 55 30 22 19 12 45 23 44 34 38","output":"BNP"},{"id":1731373343042,"input":"15\n20 20 33 98 15 6 4 1 1 1 2 3 6 14","output":"TIMING"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/learntosurf/Desktop/codingtest_algorithm_study/learntosurf/Simulation/2024-11-12-[BOJ]-#20545-기적의매매법.py","group":"local","local":true}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
money = int(input())
5+
machineduck = list(map(int, input().split()))
6+
7+
# 준현
8+
j_stock = 0
9+
j_money = money
10+
11+
for i in machineduck:
12+
if j_money >= i:
13+
j_stock += j_money // i
14+
j_money %= i
15+
16+
# 성민
17+
s_stock = 0
18+
s_money = money
19+
20+
for i in range(3, len(machineduck)):
21+
if (machineduck[i-3] > machineduck[i-2]) and (machineduck[i-2] > machineduck[i-1]) and (machineduck[i-1] > machineduck[i]):
22+
if s_money >= machineduck[i]:
23+
s_stock += s_money // machineduck[i]
24+
s_money %= machineduck[i]
25+
26+
elif (machineduck[i-3]<machineduck[i-2]) and (machineduck[i-2]<machineduck[i-1]) and (machineduck[i-1]<machineduck[i]):
27+
if s_stock > 0:
28+
s_money += s_stock * machineduck[i]
29+
s_stock = 0
30+
31+
j_result = j_money + j_stock * machineduck[-1]
32+
s_result = s_money + s_stock * machineduck[-1]
33+
34+
if j_result > s_result:
35+
print("BNP")
36+
elif j_result < s_result:
37+
print("TIMING")
38+
else:
39+
print("SAMESAME")

0 commit comments

Comments
 (0)