인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

No author

This post's author information has been deleted.

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

8. Sinking Titanic (Greedy)

테스트케이스 질문

Written on

·

217

0

안녕하세요. 문제를 풀다가 테스트케이스에서 오류가 나서 질문 드립니다. 3번과 5번 테스트케이스에서 1 차이로 오류가 나는데 이유를 알 수 있을까요? 아래는 오류가 나는 코드입니다.

import sys
#sys.stdin=open("input.txt", "rt")
n, m=map(intinput().split())
a=list(map(intinput().split()))
a.sort()
cnt=0
s=0
e=n-1
while s<=e:
    cnt+=1
    e-=1
    if a[s]+a[e]<=m:
        s+=1
print(cnt)
python코테 준비 같이 해요!

Answer 2

0

해결했습니다! if문 위치의 문제였네요. 감사합니다.

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^ 다음 입력을 가지고 버그를 찾아보세요.

8 149

71 72 73 74 75 76 77 78 149

답은 5입니다.

No author

This post's author information has been deleted.

Ask a question