BOJ 2798: 블랙잭

n, m = map(int, input().split())
cards = sorted(list(map(int, input().split())), reverse=True)
max_sum = 0

for first in range(n-2):
    for second in range(first + 1, n-1):
        for third in range(second + 1, n):
            sum = cards[first] + cards[second] + cards[third]

            if sum <= m:
                max_sum = max(max_sum, sum)
                break

print(max_sum)

BOJ 15721: 번데기

a = int(input()) #count of people
t = int(input()) #t_th
keyword = int(input()) #0: 뻔 1: 데기

turn = 1

seat_index = 0

while t > (3 + turn):
    seat_index = (seat_index + 6 + 2 * turn) % a
    t -=  3 + turn
    turn += 1

a_list = [0, 1, 0, 1] + [0] * (turn + 1) + [1] * (turn + 1)

for cur_keyword in a_list:
    if cur_keyword == keyword: t -= 1

    if t == 0:
        print(seat_index)
        break

    seat_index = (seat_index + 1) % a

BOJ 1713: 후보 추천하기

N = int(input())
recom_count = int(input())
recoms = list(map(int, input().split()))

frames = dict() #id : [recom_count, order]

for idx, recom in enumerate(recoms):

    if recom in frames.keys(): #해당 후보가 사진틀에 있으면

        frames[recom][0] += 1

    else: #해당 후보가 사진틀에 없으면

        if len(frames) == N: #사진틀에 빈 자리가 없으면

            del_key = sorted(frames.items(), key= lambda x : (x[1][0], x[1][1]))[0][0]
            #사진틀에 있는 학생들을 1. 추천 수 오름차순, 2. 추가 시기 오름차순으로 정렬 후 가장 첫 번째 학생의 id를 가져옴.
            del frames[del_key]

        frames[recom] = [1, idx]

print(*sorted(frames.keys()))