아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Aidana and Pita

면접 대비

시간 제한2초메모리 제한1024 MB

요약
n개의 피타(최대 25개)를 세 친구에게 나누어 행복도의 최댓값과 최솟값 차이를 최소로 만들고, 각 피타가 갈 친구 번호를 출력한다.
난이도

보통10점 중 5점

유형
동적 계획법, 백트래킹, 완전 탐색
정답자
아직 제출이 없습니다

문제

Aidana loves pita. Yesterday she brought home nn pitas. Each pita has a tastiness value, which is an integer. Today three friends of Aidana will come to dinner. She will distribute all nn pitas among them; each pita will go to exactly one friend. The happiness of a friend is the sum of tastiness values of all pitas he or she received. Aidana wants to be fair. So help her find a distribution of pitas that minimizes the difference between her friends' maximum and minimum happiness.

입력

The first line contains one integer nn, the number of pitas (3≤n≤25)(3 \le n \le 25).

The second line contains nn integers, a_1,a_2,…,a_na\_1, a\_2, \ldots, a\_n, which are tastiness values for pitas (1≤a_i≤1071 \le a\_i \le 10^7).

출력

Print nn integers: for each pita, print the friend's index to which this pita should go (friends' indices are 1, 2, and 3).

If there are several possible answers which minimize the difference between maximum and minimum happiness, print any one of them.

예제2

  1. 예제 1

    입력
    5
    2 3 1 4 2
    
    예상 출력
    3 2 2 1 3
    
  2. 예제 2

    입력
    6
    3 2 5 3 4 2
    
    예상 출력
    2 3 1 2 3 1