https://www.acmicpc.net/problem/1524
1524번: 세준세비
첫째 줄에 테스트 케이스의 개수 T가 주어진다. T는 100보다 작거나 같다. 각 테스트 케이스는 다음과 같이 이루어져 있다. 첫째 줄에 N과 M이 들어오고, 둘째 줄에는 세준이의 병사들의 힘이 들어
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
|
from sys import stdin
from collections import deque
def sol(sejun, sebi):
answer = 'C'
while len(sejun)!=0 and len(sebi)!=0:
if sejun[0]<sebi[0]:
sejun.popleft()
else :
sebi.popleft()
if len(sejun)>len(sebi):
answer = 'S'
elif len(sebi)>len(sejun):
answer = 'B'
return answer
if __name__ == '__main__':
t= int(input())
for i in range(t):
blank = input()
n, m= map(int,stdin.readline().split())
sejun = deque(map(int,stdin.readline().split()))
sebi = deque(map(int, stdin.readline().split()))
print(sol(sejun,sebi))
|
cs |
세준이랑 세비 각각 비교해주면서 작은쪽을 pop해주면됩니당
Comapre Sejun and Sebi, much smaller is gone(Pop)
반응형
'python-algorithm' 카테고리의 다른 글
백준 16171 나는 친구가 적다 (Small) (0) | 2022.11.13 |
---|---|
백준 17202 핸드폰 번호 궁합 (0) | 2022.11.13 |
백준 20546 🐜 기적의 매매법 🐜 (0) | 2022.11.12 |
백준 2422 한윤정이 이탈리아에 가서 아이스크림을 사먹는데 (0) | 2022.11.10 |
Hacker rank Caesar Cipher (0) | 2022.11.10 |
댓글