본문 바로가기
python-algorithm

[백준] 1246

by 무적김두칠 2021. 2. 8.

1
2
3
4
5
6
7
8
9
10
n,m=map(int, input().split())
tmp=[]
for i in range(m):
    tmp.append(int(input()))
tmp.sort()
price,ans=0,0
for i in range(m):
    mymax=min(m-i,n)
    if ans< tmp[i]*mymax: price=tmp[i]; ans=tmp[i]*mymax
print(price,ans)
cs

특이사항은 없고
line 8을 통해서 가지고 있는 달걀보다 더 큰 경우를 예외처리해줍니다.

반응형

'python-algorithm' 카테고리의 다른 글

[백준] 1439  (0) 2021.02.08
[백준] 1427  (0) 2021.02.08
[백준] 1181  (0) 2021.02.08
[백준] 1158  (0) 2021.02.08
[백준] 1145  (0) 2021.02.08

댓글