File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+
3+ input = sys .stdin .readline
4+
5+ n , m = map (int , input ().split ())
6+ a = [1 ] + list (map (int , input ().split ()))
7+
8+ def snow (size , time , idx ):
9+ global res
10+
11+ if time > m :
12+ return
13+ if time <= m :
14+ res = max (res , size )
15+ if idx + 1 <= n :
16+ snow (size + a [idx + 1 ], time + 1 , idx + 1 )
17+ if idx + 2 <= n :
18+ snow (size // 2 + a [idx + 2 ], time + 1 , idx + 2 )
19+
20+ res = 0
21+ snow (1 , 0 , 0 )
22+ print (res )
23+
24+ """
25+ 10 5
26+ 1 3 4 5 6 7 8 10 12 14
27+ """
Original file line number Diff line number Diff line change 1+ import sys
2+ from itertools import *
3+
4+ input = sys .stdin .readline
5+
6+ arr = list (map (str , input ().rstrip ()))
7+ x = int ('' .join (arr ))
8+ res = x
9+ arr .sort ()
10+
11+ for perm in permutations (arr , len (arr )):
12+ if int ('' .join (perm )) > res :
13+ res = int ('' .join (perm ))
14+ break
15+ if res == x :
16+ print (0 )
17+ else :
18+ print (res )
19+
Original file line number Diff line number Diff line change 1+ from collections import *
2+
3+ def solution (prices ):
4+ answer = []
5+
6+ queue = deque (prices )
7+ while queue :
8+ price = queue .popleft ()
9+ sec = 0
10+ for q in queue :
11+ sec += 1
12+ if price > q :
13+ break
14+ answer .append (sec )
15+
16+
17+ return answer
You can’t perform that action at this time.
0 commit comments