File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import sys
2+
3+ input = sys .stdin .readline
4+
5+ n = int (input ())
6+ dp = [0 ] * 10001
7+ dp [1 ] = 1
8+ dp [2 ] = 3
9+
10+ for i in range (3 , 10001 ):
11+ dp [i ] = dp [i - 2 ] * 2 + dp [i - 1 ]
12+
13+ print (dp [n ]% 10007 )
Original file line number Diff line number Diff line change 1+ import sys
2+
3+ input = sys .stdin .readline
4+
5+ n = int (input ())
6+ arr = list (map (int , input ().split ()))
7+
8+ max_profit = 0
9+ min_price = float ('inf' )
10+
11+ for a in arr :
12+ min_price = min (a , min_price )
13+ max_profit = max (a - min_price , max_profit )
14+
15+ print (max_profit )
Original file line number Diff line number Diff line change 1+ from collections import *
2+
3+ def solution (x , y , n ):
4+ visited = set ([x ])
5+
6+ q = deque ([(0 , x )])
7+ while q :
8+ cnt , x = q .popleft ()
9+ if x == y :
10+ return cnt
11+ for nx in (x + n , x * 2 , x * 3 ):
12+ if nx <= y and nx not in visited :
13+ visited .add (nx )
14+ q .append ((cnt + 1 , nx ))
15+
16+ return - 1
You can’t perform that action at this time.
0 commit comments