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+ arr = set ()
7+ for _ in range (n ):
8+ arr .add (int (input ()))
9+
10+ arr = sorted (arr )
11+
12+ i = 0
13+ cnt = 0
14+ for j in range (n ):
15+ while arr [j ] - arr [i ] > 4 :
16+ i += 1
17+ cnt = max (cnt , j - i + 1 )
18+
19+
20+ print (5 - cnt )
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 = list (map (int , input ().split ()))
7+
8+ cnt = 0
9+ i , j = 0 , 0
10+ total = 0
11+ while j < n :
12+ total += a [j ]
13+ while total >= m :
14+ if total == m :
15+ cnt += 1
16+ total -= a [i ]
17+ i += 1
18+ j += 1
19+
20+ print (cnt )
Original file line number Diff line number Diff line change 1+ def solution (numbers ):
2+ numbers_str = list (map (str , numbers ))
3+
4+ # numbers의 원소는 1,000 이하이므로 3번 반복
5+ numbers_str = sorted (numbers_str , key = lambda x : x * 3 , reverse = True )
6+
7+ # numbers = [0, 0, 0] 라면 -> '000' 반환
8+ return str (int ('' .join (numbers_str )))
You can’t perform that action at this time.
0 commit comments