[백준] 10431번 줄세우기

거북이·2023년 9월 19일
0

백준[실버5]

목록 보기
111/114
post-thumbnail

💡문제접근

  • 버블 정렬 느낌의 코드

💡코드(메모리 : 31256KB, 시간 : 88ms)

import sys
input = sys.stdin.readline

P = int(input())
for _ in range(P):
    height = list(map(int, input().strip().split()))
    tot = 0
    for i in range(1, len(height)-1):
        for j in range(i+1, len(height)):
            if height[i] > height[j]:
                height[i], height[j] = height[j], height[i]
                tot += 1
    print(height[0], tot)

💡소요시간 : 21m

0개의 댓글