1. Problem
2. My Solution
import sys
n = int(sys.stdin.readline())
people = list(map(int,sys.stdin.readline().rstrip().split()))
sum = 0
res = 0
people.sort()
for i in range(n):
sum += people[i]
res += sum
print(res)
1. Problem
2. Others' Solutions
import sys
sys.setrecursionlimit(10**5)
# 대각선 방향 체크(Backtracking)
def check(r,c):
for i in range(1,r+1):
if board[r-i] == c-i or board[r-i] == c + i :
return False
return True
def dfs(row):
global count
if row >= n:
count += 1
else:
for i in range(n):
# 열 방향 체크(Backtracking)
if col_visited[i] == True:
continue
else:
if check(row,i) == True:
col_visited[i] = True
board[row] = i
dfs(row+1)
col_visited[i] = False
n = int(sys.stdin.readline())
board = [-1] * n
col_visited = [False] * n
count = 0
dfs(0)
print(count)
3. Learned
for i in range(r):
if board[r] == board[i] or abs(board[r]-board[i]) == r-i:
return False
return True