1. Problem
2. My Solution
import sys
n = int(sys.stdin.readline())
seq = list(map(int,sys.stdin.readline().rstrip().split()))
flag = False
for i in range(len(seq)-1, 0,-1):
if seq[i-1] > seq[i]: # 오른쪽을 시작으로 오름차순이 되는 index 찾음
start = i-1
flag = True
for j in range(len(seq)-1, start, -1): # Increasing Section 에서 index 값보다 작은 첫 번째 요소와 swap
if seq[j] < seq[start]:
seq[j], seq[start] = seq[start], seq[j]
break
start = start+1
end = len(seq)-1
while(start < end): # Increasing Section 내림차순으로 정리
seq[start], seq[end] = seq[end], seq[start]
start += 1
end -= 1
break
if flag == True:
print(*seq)
else:
print(-1)
1. Problem
2. My Solution
import sys
n,s = map(int,sys.stdin.readline().rstrip().split())
seq = list(map(int,sys.stdin.readline().rstrip().split()))
count = 0
for i in range(1,1 << n):
sum = 0
for j in range(n):
if i & (1 << j):
sum += seq[j]
if sum == s:
count += 1
print(count)
3. Others' Solutions
from itertools import combinations
n, s = map(int, input().split())
cnt = 0
a = list(map(int, input().split()))
for i in range(1, n+1):
b = list(combinations(a, i))
for j in b:
if sum(j) == s:
cnt += 1
print(cnt)
4. Learned