https://www.acmicpc.net/problem/2217
N = int(input())
ropes = sorted([int(input()) for _ in range(N)],reverse = True)
answer = 0
while(ropes):
answer = max(answer,ropes[-1]*len(ropes))
ropes.pop()
print(answer)
Time cost가 있음 왜일까~
max = O(n)이기 때문에 루프안에서 max 사용하는 것이 좋지 않음
import sys
N = int(input())
rope_list = {}
for _ in range(N):
rope = int(sys.stdin.readline())
if rope in rope_list.keys():
rope_list[rope] += 1
else:
rope_list[rope] = 1
sorted_rope_list = sorted(rope_list, reverse = True)
big_rope = sorted_rope_list[0]
n_rope = rope_list[big_rope]
answer = big_rope * n_rope
for key in sorted_rope_list[1:]:
n_rope += rope_list[key]
answer = max(answer, key*n_rope)
print(answer)
import sys
sys.stdin.readline()
으로 input을 받으면 속도가 많이 개선된다!