CF873E.Awards For Contestants

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alexey recently held a programming contest for students from Berland. nn students participated in a contest, ii -th of them solved aia_{i} problems. Now he wants to award some contestants. Alexey can award the students with diplomas of three different degrees. Each student either will receive one diploma of some degree, or won't receive any diplomas at all. Let cntxcnt_{x} be the number of students that are awarded with diplomas of degree xx ( 1<=x<=31<=x<=3 ). The following conditions must hold:

  • For each xx ( 1<=x<=31<=x<=3 ) cnt_{x}>0 ;
  • For any two degrees xx and yy cntx<=2cntycnt_{x}<=2·cnt_{y} .

Of course, there are a lot of ways to distribute the diplomas. Let bib_{i} be the degree of diploma ii -th student will receive (or 1-1 if ii -th student won't receive any diplomas). Also for any xx such that 1<=x<=31<=x<=3 let cxc_{x} be the maximum number of problems solved by a student that receives a diploma of degree xx , and dxd_{x} be the minimum number of problems solved by a student that receives a diploma of degree xx . Alexey wants to distribute the diplomas in such a way that:

  1. If student ii solved more problems than student jj , then he has to be awarded not worse than student jj (it's impossible that student jj receives a diploma and ii doesn't receive any, and also it's impossible that both of them receive a diploma, but b_{j}<b_{i} );
  2. d1c2d_{1}-c_{2} is maximum possible;
  3. Among all ways that maximize the previous expression, d2c3d_{2}-c_{3} is maximum possible;
  4. Among all ways that correspond to the two previous conditions, d3c1d_{3}-c_{-1} is maximum possible, where c1c_{-1} is the maximum number of problems solved by a student that doesn't receive any diploma (or 00 if each student is awarded with some diploma).

Help Alexey to find a way to award the contestants!

输入格式

The first line contains one integer number nn ( 3<=n<=30003<=n<=3000 ).

The second line contains nn integer numbers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=50001<=a_{i}<=5000 ).

输出格式

Output nn numbers. ii -th number must be equal to the degree of diploma ii -th contestant will receive (or 1-1 if he doesn't receive any diploma).

If there are multiple optimal solutions, print any of them. It is guaranteed that the answer always exists.

输入输出样例

  • 输入#1

    4
    1 2 3 4
    

    输出#1

    3 3 2 1 
    
  • 输入#2

    6
    1 4 3 1 1 2
    

    输出#2

    -1 1 2 -1 -1 3 
    
首页