[Python][백준 10989] 수 정렬하기

김바덕·2023년 6월 5일

백준

목록 보기
6/23
post-thumbnail


나의 삽질 기록들......

문제

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

메모리 제한이 8MB로 굉장히 작다. 그래서 계속 메모리 초과 에러가 발생해서 푸는데 애를 먹었다.

메모리 초과 발생 이유
(1) sort(),sorted() 사용
(2) sys.stdin.readline이 아닌 그냥 input()를 사용
(3) for 문 안에 append를 작성

import sys

N = int(sys.stdin.readline())
arr = [0]*10001

for i in range(N):
    a = int(sys.stdin.readline())
    arr[a] += 1

for i in range (len(arr)):
  if arr[i] != 0:
    for j in range(arr[i]):
        print(i)
profile
UXUI Designer

0개의 댓글