# 프로그래머스 문제 '완주하지 못한 선수'
# https://programmers.co.kr/learn/courses/30/lessons/42576

def solution(participant, completion):
    p_dict = dict()

    for player in participant:
        p_dict[player] = p_dict.get(player, 0) + 1

    for player in completion:
        p_dict[player] = p_dict[player] - 1

        if p_dict[player] == 0:
            del p_dict[player]

    answer = p_dict.popitem()[0]
    return answer


if __name__=='__main__':

    test_cases = [
        {
            'participant': ["leo", "kiki", "eden"],
            'completion': ["eden", "kiki"],
            'answer': "leo"
        },
        {
            'participant': ["marina", "josipa", "nikola", "vinko", "filipa"],
            'completion': ["josipa", "filipa", "marina", "nikola"],
            'answer': "vinko"
        },
        {
            'participant': ["mislav", "stanko", "mislav", "ana"],
            'completion': ["stanko", "ana", "mislav"],
            'answer': "mislav"
        }
    ]

    for test_case in test_cases:
        participant = test_case['participant']
        completion = test_case['completion']
        answer = test_case['answer']
        my_answer = solution(participant, completion)
        print(f'answer: {answer}, my_answer: {my_answer}')
# swea 5356 '의석이의 세로로 말해요'

T = int(input())

for t in range(1, T+1):
    my_dict = {}
    for i in range(15):
        my_dict[i] = ''
    
    for _ in range(5):
        string = input()
        
        for i, c in enumerate(string):
            my_dict[i] += c
    
    print('#{}'.format(t), end=' ')
    for i in range(15):
        if len(my_dict[i]):
            print(my_dict[i], end='')
        else:
            break
    print()
# swea 6485 '삼성시의 버스 노선'

T = int(input())
for t in range(1, T+1):
    n = int(input())
    
    bus_stops = [0 for _ in range(5001)]
    for _ in range(0, n):
        a, b = map(int, input().split())
        for i in range(a, b + 1):
            bus_stops[i] += 1

    p = int(input())

    result_list = []
    for _ in range(p):
        c = int(input())

        result_list.append(bus_stops[c])
    
    print('#{}'.format(t), end=' ')
    print(*result_list, sep=' ')
# swea 1961 '숫자 배열 회전'

T = int(input())

for t in range(1, T+1):
    N = int(input())
    MAP = []
    for _ in range(N):
        MAP.append(list(input().split()))
    
    result_list = [[] for _ in range(N)]

    result_idx = 0
    for j in range(N):
        result = ''
        for i in range(N-1, -1, -1):
            result += MAP[i][j]
        result_list[result_idx].append(result)
        result_idx += 1
    
    result_idx = 0
    for i in range(N-1, -1, -1):
        result = ''
        for j in range(N-1, -1, -1):
            result += MAP[i][j]
        result_list[result_idx].append(result)
        result_idx += 1
    
    result_idx = 0
    for j in range(N-1, -1, -1):
        result = ''
        for i in range(N):
            result += MAP[i][j]
        result_list[result_idx].append(result)
        result_idx += 1
    
    print('#{}'.format(t))

    for i in range(N):
        print(*result_list[i], sep=' ')
# swea 1859 '백만 장자 프로젝트'

T = int(input())

for t in range(1, T+1):
    N = int(input())
    price_list = list(map(int, input().split()))

    i = 0
    result = 0
    while i < len(price_list):
        max_price = -1
        max_idx = -1

        for j in range(i, len(price_list)):
            if max_price < price_list[j]:
                max_price = price_list[j]
                max_idx = j
        
        buy_price = 0

        for j in range(i, max_idx + 1):
            buy_price += price_list[j]
            
        sell_price = max_price * (max_idx - i + 1)
        result += (sell_price - buy_price)

        i = max_idx + 1
    
    print('#{} {}'.format(t, result))
# swea 5432 '쇠막대기 자르기'

T = int(input())

for t in range(1, T+1):
    st = input()

    cnt = 0
    stk = []
    flag = False
    for s in st:
        if s == '(':
            stk.append(0)
            flag = True
        else:
            if flag:
                stk.pop()
                cnt += len(stk)
            else:
                stk.pop()
                cnt += 1
            flag = False
    
    print('#{} {}'.format(t, cnt))
# swea 1974 '스도쿠 검증'

T = int(input())

for t in range(1, T+1):
    MAP = []
    for _ in range(9):
        MAP.append(list(map(int, input().split())))
    
    row_check = [[False for num in range(10)] for row in range(9)]
    col_check = [[False for num in range(10)] for col in range(9)]
    box_check = [[False for num in range(10)] for box in range(9)]

    result = 1
    for row in range(9):
        for col in range(9):
            num = MAP[row][col]
            box = 3*(row // 3) + (col // 3)
            if row_check[row][num] or col_check[col][num] or box_check[box][num]:
                result = 0
                break
            row_check[row][num] = True
            col_check[col][num] = True
            box_check[box][num] = True
        if result == 0:
            break
    
    print('#{} {}'.format(t, result))
# swea 4408 '자기 방으로 돌아가기'

class Move:
    def __init__(self, st, fn):
        if st > fn:
            st, fn = fn, st
        self.st = (st - 1) // 2
        self.fn = (fn - 1) // 2


T = int(input())

for t in range(1, T+1):
    N = int(input())

    move_list = []
    for _ in range(N):
        st, fn = map(int, input().split())
        move_list.append(Move(st, fn))
    
    move_list.sort(key=lambda move: move.st)

    cnt = 0
    while len(move_list):
        st = move_list[0].st
        fn = move_list[0].fn
        move_list.pop(0)

        i = 0
        while i < len(move_list):
            move = move_list[i]
            if move.st > fn:
                fn = move.fn
                move_list.pop(i)
                continue
            i += 1
        
        cnt += 1
    
    print('#{} {}'.format(t, cnt))

+ Recent posts