python-algorithm

백준 14696 딱지놀이

무적김두칠 2022. 10. 28. 12:52

https://www.acmicpc.net/problem/14696

 

14696번: 딱지놀이

표준 입력으로 다음 정보가 주어진다. 첫 번째 줄에는 딱지놀이의 총 라운드 수를 나타내는 자연수 N이 주어진다. N 은 1 이상 1,000 이하이다. 다음 줄에는 라운드 1에서 어린이 A가 내는 딱지에 나

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def sol(a_nums,b_nums):
    a_len, a_nums = a_nums[0], a_nums[1:]
    b_len, b_nums = b_nums[0], b_nums[1:]
    a_nums.sort(reverse=True)
    b_nums.sort(reverse=True)
    if a_nums==b_nums:
        return 'D'
    for i in range(min(a_len, b_len)):
        if a_nums[i] > b_nums[i]:
            return 'A'
        elif a_nums[i] < b_nums[i]:
            return 'B'
        else:
            pass
    if a_len > b_len:
        return 'A'
    else:
        return 'B'
 
n=int(input())
for i in range(n):
    a_nums = list(map(int, input().split()))
    b_nums = list(map(int, input().split()))
 
    print(sol(a_nums,b_nums))
 
cs

정렬하고 비교하면 되는 문제죠 

Sort and Compare the number

반응형