강의

멘토링

커뮤니티

Inflearn Community Q&A

ajw7117948's profile image
ajw7117948

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

10. Inverse sequence (greedy)

이렇게 풀어도 되는지 모르겠습니다

Written on

·

305

·

Edited

0

import sys
sys.stdin=open("input.txt","rt")

n=int(input())
ls=list(map(int, input().split()))
res=[0]*n
for i in range(n):
    check = ls[i]
    count = 0  
    for j in range(n):
        if res[j] == 0:
            if count == check:
                res[j] = i + 1
                break
            else:
                count += 1
       
for x in res:
    print(x, end=" ")
python코딩-테스트

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

네. 잘 하신 코드입니다.

ajw7117948's profile image
ajw7117948

asked

Ask a question