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+ from itertools import product
2+ n , m = map (int , input ().split ())
3+ arr = list (map (int , input ().split ()))
4+
5+ dx = [1 , 2 ]
6+
7+ max = float ("-inf" )
8+
9+ for p in product (dx , repeat = m ):
10+ now = - 1
11+ snow = 1
12+ for i in p :
13+ if i == 1 :
14+ now += 1
15+ if now < n :
16+ snow += arr [now ]
17+ elif i == 2 :
18+ now += 2
19+ if now < n :
20+ snow //= 2
21+ snow += arr [now ]
22+ if snow > max :
23+ max = snow
24+
25+ print (max )
Original file line number Diff line number Diff line change 1+ from itertools import permutations
2+
3+ x = input ()
4+
5+ min = float ("inf" )
6+
7+ for p in permutations (x , len (x )):
8+ num = '' .join (p )
9+ if int (x ) < int (num ) < min :
10+ min = int (num )
11+
12+ if min == float ("inf" ):
13+ print (0 )
14+ else :
15+ print (min )
Original file line number Diff line number Diff line change 1+ def solution (prices ):
2+ answer = []
3+
4+ for i in range (len (prices )):
5+ sec = 0
6+ for j in range (i + 1 , len (prices )):
7+ sec += 1
8+ if prices [i ] > prices [j ]:
9+ break
10+ answer .append (sec )
11+ return answer
You can’t perform that action at this time.
0 commit comments